HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<div class="container">
<header class="header">
<h1 id="title" class="text-center">アンケート</h1>
<p id="description" class="description text-center">
ご協力ありがとうございます。
</p>
</header>
<form id="survey-form">
<div class="form-group">
<label id="name-label" for="name">氏名</label>
<input
type="text"
name="name"
id="name"
class="form-control"
placeholder="おなまえ たろう"
required
/>
</div>
<div class="form-group">
<label id="email-label" for="email">メール</label>
<input
type="email"
name="email"
id="email"
class="form-control"
placeholder="***@***.mail.com"
required
/>
</div>
<div class="form-group">
<label id="number-label" for="number"
>年齢<span class="clue">(任意)</span></label
>
<input
type="number"
name="age"
id="number"
min="10"
max="99"
class="form-control"
placeholder="18"
/>
</div>
<div class="form-group">
<p>習熟度</p>
<select id="dropdown" name="role" class="form-control" required>
<option disabled selected value>習熟度を選んでください</option>
<option value="student">学生</option>
<option value="job">職業</option>
<option value="learner">学習中</option>
<option value="preferNo">ひみつ</option>
<option value="other">その他</option>
</select>
</div>
<div class="form-group">
<p>友人にオススメできますか?</p>
<label>
<input
name="user-recommend"
value="definitely"
type="radio"
class="input-radio"
checked
/>はい</label
>
<label>
<input
name="user-recommend"
value="maybe"
type="radio"
class="input-radio"
/>たぶん</label
>
<label
><input
name="user-recommend"
value="not-sure"
type="radio"
class="input-radio"
/>いいえ</label
>
</div>
<div class="form-group">
<p>
本サイトで気に入ったものはなんですか?
</p>
<select id="most-like" name="mostLike" class="form-control" required>
<option disabled selected value>選択肢から選んでください</option>
<option value="challenges">チャレンジ</option>
<option value="projects">プロジェクト</option>
<option value="community">コミュニティ</option>
<option value="openSource">Oオープンソース</option>
</select>
</div>
<div class="form-group">
<p>
改善が必要なところはどこだと思いますか?
<span class="clue">(当てはまるものすべて)</span>
</p>
<label
><input
name="prefer"
value="front-end-projects"
type="checkbox"
class="input-checkbox"
/>フロントエンドプロジェクト</label
>
<label>
<input
name="prefer"
value="back-end-projects"
type="checkbox"
class="input-checkbox"
/>バックエンドプロジェクト</label
>
<label
><input
name="prefer"
value="data-visualization"
type="checkbox"
class="input-checkbox"
/>データビジュアライゼーション</label
>
<label
><input
name="prefer"
value="challenges"
type="checkbox"
class="input-checkbox"
/>チャレンジ</label
>
<label
><input
name="prefer"
value="open-source-community"
type="checkbox"
class="input-checkbox"
/>オープンソースコミュニティ</label
>
<label
><input
name="prefer"
value="gitter-help-rooms"
type="checkbox"
class="input-checkbox"
/>ヘルプルーム</label
>
<label
><input
name="prefer"
value="videos"
type="checkbox"
class="input-checkbox"
/>動画</label
>
<label
><input
name="prefer"
value="city-meetups"
type="checkbox"
class="input-checkbox"
/>ミートアップ</label
>
<label
><input
name="prefer"
value="wiki"
type="checkbox"
class="input-checkbox"
/>Wiki</label
>
<label
><input
name="prefer"
value="forum"
type="checkbox"
class="input-checkbox"
/>フォーラム</label
>
<label
><input
name="prefer"
value="additional-courses"
type="checkbox"
class="input-checkbox"
/>追加コース</label
>
</div>
<div class="form-group">
<p>その他になにかあればコメントお願いします。</p>
<textarea
id="comments"
class="input-textarea"
name="comment"
placeholder="コメントを入力してください"
></textarea>
</div>
<div class="form-group">
<button type="submit" id="submit" class="submit-button">
送信
</button>
</div>
</form>
</div>
@import url('https://fonts.googleapis.com/css?family=Kosugi+Maru&display=swap');
:root {
--color-white: #f3f3f3;
--color-yellow: #F0E30E;
--color-darkblue-alpha: rgba(27,3,4, 0.6);
--color-brown: #110205;
}
*,
*::before,
*::after {
box-sizing: border-box;
}
body {
font-family: 'Kosugi Maru';
font-size: 1rem;
font-weight: 400;
line-height: 1.4;
color: var(--color-white);
margin: 0;
&::before {
content: '';
position: fixed;
top: 0;
left: 0;
height: 100%;
width: 100%;
z-index: -1;
background: var(--color-yellow);
background-image: linear-gradient(
180deg,
rgba(242,229,16, 0.8),
rgba(182,59,0, 0.7)
),
url('https://i.imgur.com/yBoW0DB.jpg');
background-size: cover;
background-repeat: no-repeat;
background-position: center;
}
}
@mixin textLayout {
margin-top: 0;
margin-bottom: 0.5rem;
}
h1 {
@include textLayout;
font-weight: 400;
line-height: 1.2;
}
p {
@include textLayout;
font-size: 1.125rem;
}
label {
display: flex;
align-items: center;
font-size: 1.125rem;
margin-bottom: 0.5rem;
}
input,
button,
select,
textarea {
margin: 0;
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
button {
border: none;
}
.container {
width: 100%;
margin: 3.125rem auto 0 auto;
}
@media (min-width: 576px) {
.container {
max-width: 540px;
}
}
@media (min-width: 768px) {
.container {
max-width: 720px;
}
}
.header {
color: black;
padding: 0 0.625rem;
margin-bottom: 1.875rem;
}
.description {
font-style: italic;
font-weight: 200;
text-shadow: 1px 1px 1px rgba(0, 0, 0, 0.4);
}
.clue {
margin-left: 0.25rem;
font-size: 0.9rem;
color: #e4e4e4;
}
.text-center {
text-align: center;
}
form {
background: var(--color-darkblue-alpha);
padding: 2.5rem 0.625rem;
border-radius: 0.25rem;
}
@media (min-width: 480px) {
form {
padding: 2.5rem;
}
}
.form-group {
margin: 0 auto 1.25rem auto;
padding: 0.25rem;
}
.form-control {
display: block;
width: 100%;
height: 2.375rem;
padding: 0.375rem 0.75rem;
color: #495057;
background-color: #fff;
background-clip: padding-box;
border: 1px solid #ced4da;
border-radius: 0.25rem;
transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}
.form-control:focus {
border-color: #80bdff;
outline: 0;
box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}
.input-radio,
.input-checkbox {
display: inline-block;
margin-right: 0.625rem;
min-height: 1.25rem;
min-width: 1.25rem;
}
.input-textarea {
min-height: 120px;
width: 100%;
padding: 0.625rem;
resize: vertical;
}
.submit-button {
display: block;
width: 100%;
padding: 0.75rem;
background: var(--color-brown);
color: inherit;
border-radius: 2px;
cursor: pointer;
}
const projectName = 'survey-form';
Also see: Tab Triggers