Gunnar Bittersmann: Welche Bedeutung hat das "class" Attribute heute noch?

Beitrag lesen

@@Rolf B

Eine space-getrennte Aufzählung in einem einzigen data-Attribut wird Dir sicherlich nicht vorschweben (vor allem, weil man dann kaum einen CSS Selektor zustande bringt, der abfragt, ob ein Element 2 von 5 möglichen „data-Klassen“ hat.

Hold my beer.

Ein Klassenselektor .foo ist – aus CSS-Sicht – nicht anderes als eine kürzere Schreibweise für einen Attributselektor [class~="foo"]. .foo.bar ist nichts anderes als [class~="foo"][class~="bar"].

Und statt class kann man im Attributselektor ja auch andere Attribute abfragen.

Man sollte davon ausgehen, dass der Umgang mit class speziell in den Layout-Engines optimiert ist.

Ja. Deshalb oben „aus CSS-Sicht“. Aus Browser-Engine-Sicht mag das in der Tat anders aussehen.

😷 LLAP

--
“When I was 5 years old, my mother always told me that happiness was the key to life. When I went to school, they asked me what I wanted to be when I grew up. I wrote down ‘happy.’ They told me I didn’t understand the assignment, and I told them they didn’t understand life.” —John Lennon