class
class
グローバル属性 は、要素のクラスを空白区切りで並べたリストで、大文字小文字を区別します。クラスは CSS の クラスセレクター や JavaScript の DOM メソッド document.getElementsByClassName
といった関数により、特定の要素を選択したり特定の要素にアクセスしたりすることを可能にします。
試してみましょう
仕様書ではクラス名の要件を示していませんが、ウェブ開発者は要素の外見ではなく、意味論的な目的を表す名前を使用することが推奨されます。例えば、あるクラスの要素が イタリック体 で表示されるとしても、クラス名は attribute の方が italics よりも属性を説明します。意味論的な名前は、ページの外見を変更した場合でも論理的であり続けます。
仕様書
Specification |
---|
HTML # global-attributes:classes-2 |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
class |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.