Menu
Coddy logo textTech

Input と Label

Coddyの「ログインフォーム - HTML/CSSプロジェクト」コースのレッスン 2/7。

<input> タグは、テキストフィールド、チェックボックス、ラジオボタン、送信ボタンなど、さまざまな種類の入力要素のためのコンテナです。

type 属性を使用してタイプを設定します。

<input type="text">
<input type="radio">
<input type="checkbox">
<input type="password">
<input type="submit">

入力に <label> タグを追加するのが良い習慣です。

<label for="password">Password:</label>
<input type="text" id="password">

これらを関連付けるために、for 属性は入力の id 属性と一致させる必要があることに注意してください。

challenge icon

チャレンジ

簡単

"username""password"というidを持つ、ラベル付きの2つのinput要素を追加し、inputのtypeを"text""password"に設定してください。各ラベルをそのinputにリンクさせるのを忘れないでください。

各要素の間にスペースを作るために、<br/>タグを追加することをお勧めします!

自分で試してみよう

<!DOCTYPE html>
<html>
<head>
    <link rel="stylesheet" href="styles.css">
</head>
<body>
    <!-- Write HTML code here -->
</body>
</html>

ログインフォーム - HTML/CSSプロジェクトのすべてのレッスン