+ 1
HTML - Does using two dashes in class = "" mean anything? (class = "a--blue")
On some html codes I see, they declare their class names something like this: "btn btn--positive" So, do the two dashes have some kind of function, or are they just there for the developer to understand what that button is.
4 Antworten
+ 2
Many developers use it to denote a class that describes state. e.g nav--open, box--checked. However it is just convention
+ 5
Pretty sure it's done for readability
+ 3
Ginfio What you are seeing the css class .btn .btn--positive, a--blue are followed a naming convention called BEM (The Block, Element, Modifier methodology).
In BEM, Modifiers are written in camel case and are preceded by two dashes --.
The standard syntax for BEM is:
block-name__element-name--modifier-name (B__E–M)
such as, .subscribedForm__input--checked
To know more about BEM refer to https://css-tricks.com/bem-101/
BEM is implemented well in postCSS
https://webdesign.tutsplus.com/tutorials/using-postcss-with-bem-and-suit-methodologies--cms-24592
+ 2
Maybe it's part of some library or framework, otherwise probably just stylistic choice