---
title: class
slug: Web/HTML/Global_attributes/class
tags:
  - Global attributes
  - HTML
  - Reference
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/)
