-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
29 lines (19 loc) · 1.29 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
---
title: class
slug: Web/HTML/Global_attributes/class
page-type: html-attribute
browser-compat: html.global_attributes.class
---
{{HTMLSidebar("Global_attributes")}}
The **`class`** [global attribute](/en-US/docs/Web/HTML/Global_attributes) is a space-separated list of the case-sensitive classes of the element. Classes allow CSS and JavaScript to select and access specific elements via the [class selectors](/en-US/docs/Web/CSS/Class_selectors) or functions like the DOM method {{domxref("document.getElementsByClassName")}}.
{{EmbedInteractiveExample("pages/tabbed/attribute-class.html","tabbed-standard")}}
Though the specification doesn't put requirements on the name of classes, web developers are encouraged to use names that describe the semantic purpose of the element, rather than the presentation of the element. For example, _attribute_ to describe an attribute rather than _italics_, although an element of this class may be presented by _italics_. Semantic names remain logical even if the presentation of the page changes.
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- All [global attributes](/en-US/docs/Web/HTML/Global_attributes).
- {{domxref('element.className')}}
- {{domxref('element.classList')}}
- [Introduction to CSS](/en-US/docs/Learn/CSS)