Orientation of a class value starting with a space

I want to make a CSS selector for a class that starts with a space, but I don't know how to do it. For example: <table class=" example">…</table>.

+4
source share
3 answers

Any leading or trailing spaces in the value of a class attribute do not make sense for targeting purposes. It: class=" example"is equivalent to this: class="example".

There is no need for a special selector that affects the space.

From the HTML 5 spec:

2.4.7 Space sharing tokens

A string containing a set of space-separated tokens can have either run characters.

, , .

3.2.5.7 class

, , , , , .

+3

CSS - ; .

.example.

+3

. class=" example" HTML class="example", class="example " class=" example " .example.

, , .example.

, , : [class~="example"] , [class="example"] class="example". (, , - , , , [class^=" example"], [class=" example"], , , , .)

+3

Source: https://habr.com/ru/post/1661318/


All Articles