CSS - Selector

About

Selector API in the CSS context.

When a user agent can't parse the selector (i.e., it is not valid CSS), it ignores the declaration block. The whole statement is ignored if there is an error anywhere in the selector.

It's an important element of the CSS addressing (selecting) model.

Syntax

In CSS, the selector consists of everything up to (but not including) the first left curly brace ({) of a declaration block.

Identifier Naming

identifiers (including element names, classes, and IDs in selectors):

  • can contain only:
    • the characters [a-zA-Z0-9] and ISO 10646 characters U+00A0 and higher,
    • plus the hyphen (-) and the underscore (_);
  • cannot start with:
    • a digit,
    • two hyphens, or a hyphen followed by a digit.

More, see the identifier specification

How to select an id with a number

You need to use a full qualified selector expression

  • In place of using
h1#2019-10-01 {
    color:blue;
}
  • You use:
h1[id="2019-10-01"] {
    color:blue;
}
  • To select this h1
<h1 id="2019-10-01">Hallo World</h1>
  • Output:

Documentation / Reference


Powered by ComboStrap