【HTLM】HTMLタグの基本的な構文を押さえておく

HTMLを書く時に使うタグを整理しておく。

wordpressで作成しているため、
wordpressのテーマのCSSがあたっており、CSSを設定していないのにデザインがそれなりに整っています。
一旦、ここではHTMLの基本だけを記載しているので、CSSが気になる場合はChromeのデベロッパーツールなどで確認してください。


入力

とりあえず入力エリア(input)


HTML

<input type=”text”>

valueで値を持たせることもできます。その場合は以下。

HTML
<input type=”text” value=”abc”>

ボタン

inputタグでボタン


HTML

<input type=”button” class=”sample-button” value=”ボタン”>

CSS

input[type=”button”].sample-button {
   width: 200px;
   border-radius: 2px;
   background-color: #99CCFF;
   color: black;
   border: 1px solid black;
   cursor: pointer;
}


buttonタグでボタン

typeは、button、submit、resetが設定できる


HTML

<button type=button class=”sample-button”>ボタン</button>

CSS

button[type=”button”].sample-button {
   width: 200px;
   border-radius: 2px;
   background-color: #99CCFF;
   color: black;
   border: 1px solid black;
   cursor: pointer;
}


チェックボックス

特に装飾とかしてないので、雑ですがとりあえず。





HTML

<div class=”customCheck”>
  <input type=”checkbox” for=”chk1″ id=”chk1″>
  <label for=”chk1″>A</label>
  <input type=”checkbox” for=”chk2″ id=”chk2″>
  <label for=”chk2″>B</label>
</div>

CSS

.customCheck {
  display: flex;
  align-items: center;
}
.customCheck input {
  margin-right: 5px;
}
.customCheck label {
  width: 50px;
  margin-right: 10px;
}


ラジオボタン

特に装飾とかしてないので、雑ですがとりあえず。





HTML

<div class=”customCheck”>
  <input type=”radio” name=”rdo” id=”rdo1″>
  <label for=”rdo1″>A</label>
  <input type=”radio” name=”rdo” id=”rdo2″>
  <label for=”rdo2″>B</label>
</div>

CSS

.customCheck {
display: flex;
align-items: center;
}
.customCheck input {
margin-right: 5px;
}
.customCheck label {
width: 50px;
margin-right: 10px;
}


テキストエリア


HTML

<textarea rows=”5″></textarea>


スライダー

スライダーに関しては、こちらも参考にしてもらえると嬉しいです。

inputタグでスライダー


HTML

<input type=”range” value=”1″ min=”0″ max=”100″ step=”1″>