Edgar Ehritt: Welche Zeichen sind im class-Attribut erlaubt?

Beitrag lesen

Hallo WiMu,

aus 7.5.2 Element identifiers: the id and class attributes ergibt sich für Attribut class der Inhalt "cdata-list [CS]". Das liest sich dann, folgt man den Verweisen dort, als:

CDATA is a sequence of characters from the document character set and
   may include character entities. User agents should interpret attribute
   values as follows:

* Replace character entities with characters,
      * Ignore line feeds,
      * Replace each carriage return or tab with a single space.

i. V. m.

CS The value is case-sensitive (i.e., user agents interpret "a" and "A" differently).

D. h., anders als Du es annimmst, es kann u. a. eben auch Leerzeichen verwendet werden. Das hat ganz praktische Nebenwirkungen:

.a {background:red}  
.b {color:yellow}  
.c {border:blue}
<div class="a">     Test 1</div>  
<div class="b c">   Test 2</div>  
<div class="a c">   Test 3</div>  
<div class="a b c"> Test 4</div>

Für Attribut id ist demgegenüber der Inhalt "name [CS]", was dann bedeutet:

ID and NAME tokens must begin with a letter ([A-Za-z]) and may be
   followed by any number of letters, digits ([0-9]), hyphens ("-"),
   underscores ("_"), colons (":"), and periods (".").

Gruß aus Berlin!
eddi