Spec-Zone.ru › CSS

CSS selectors

CSS selectors are patterns used in CSS rules to target and select specific elements for styling.

Note: This page is an index of all selectors in CSS. The CSS selectors page introduces the module that defines some, but not all, of these selectors.

For example, to style paragraphs, you will use the p type selector to select all <p> elements and apply a style to them:

/* Set font size on all <p> elements */
p {
  font-size: 12px;
  color: rebeccapurple;
}

Syntax

/* Select elements and apply styles */
selector {
  property: value;
}

Index of selectors

  • & nesting selector
  • Attribute selectors
  • Class selectors
  • ID selectors
  • Keyframe selectors
  • Namespace separator (|)
  • Pseudo-class selectors
  • Pseudo-element selectors
  • Selector list
  • Type selectors
  • Universal selectors

Specifications

Specification
Selectors Level 4

Check the pseudo-classes and pseudo-elements pages for their respective specification tables.

See also

  • CSS selectors module
  • CSS selector structure
  • CSS combinators
  • Selector list
  • Selectors and combinators
  • CSS pseudo-elements module
  • CSS nesting module
  • Specificity

© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API