CSS基礎 練習問題 1:CSSセレクタ(classセレクタ)
クラスセレクタを使ってHTMLのclassに対してスタイルを当てる場合、正しいCSSの書き方はどれですか?
```html
<p class="red-text">このテキストを赤くしたい</p>
```
- red-text { color: red; }
- .red-text { color: red; }
- #red-text { color: red; }
- class red-text { color: red; }
- [red-text] { color: red; }
Qraftユーザーの成績:正答率 86%(19/22回正解)
正解と解説を見る
正解:.red-text { color: red; }
CSSでclassセレクタを指定する場合、クラス名の先頭にドット(.)を付けます。ドット(.)で「クラス」を表し、`#`はIDセレクタ、記号なしは要素セレクタになります。