You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+33-21Lines changed: 33 additions & 21 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,14 +60,15 @@ Finally, properties are what give the selected elements of a rule declaration th
60
60
61
61
### Formatting
62
62
63
-
* Use soft tabs (2 spaces) for indentation
63
+
* Use soft tabs (2 spaces) for indentation.
64
64
* Prefer dashes over camelCasing in class names.
65
-
* Do not use ID selectors
65
+
* Do not use ID selectors.
66
+
* Do not use underscores, except to override an existing or external style.
66
67
* When using multiple selectors in a rule declaration, give each selector its own line.
67
-
* Put a space before the opening brace `{` in rule declarations
68
+
* Put a space before the opening brace `{` in rule declarations.
68
69
* In properties, put a space after, but not before, the `:` character.
69
-
* Put closing braces `}` of rule declarations on a new line
70
-
* Put blank lines between rule declarations
70
+
* Put closing braces `}` of rule declarations on a new line.
71
+
* Put blank lines between rule declarations.
71
72
72
73
**Bad**
73
74
@@ -108,27 +109,20 @@ Finally, properties are what give the selected elements of a rule declaration th
108
109
109
110
### Naming Convention
110
111
111
-
**Example**
112
-
113
-
```jsx
114
-
// ListingCard.jsx
115
-
functionListingCard() {
116
-
return (
117
-
<article class="listing-card featured">
118
-
119
-
<h1 class="title">Adorable 2BRin the sunny Mission</h1>
112
+
The naming convention is a simplified version of [BEM](http://getbem.com/naming/).
120
113
121
-
<div class="content">
122
-
<p>Vestibulum id ligula porta felis euismod semper.</p>
123
-
</div>
114
+
**Example**
124
115
125
-
</article>
126
-
);
127
-
}
116
+
```html
117
+
<articleclass="listing-card featured">
118
+
<h1class="title">Adorable 2BR in the sunny Mission</h1>
119
+
<divclass="content">
120
+
<p>Vestibulum id ligula porta felis euismod semper.</p>
121
+
</div>
122
+
</article>
128
123
```
129
124
130
125
```css
131
-
/* ListingCard.css */
132
126
.listing-card { }
133
127
.listing-card.featured { }
134
128
.listing-card.title { }
@@ -139,6 +133,24 @@ function ListingCard() {
139
133
*`.listing-card .title` is an “element” and represents a descendant of `.listing-card` that helps compose the block as a whole.
140
134
*`.listing-card.featured` is a “modifier” and represents a different state or variation on the `.listing-card` block.
141
135
136
+
HTML tag names may be used instead of a class name to represent BEM-like elements.
137
+
138
+
**Example**
139
+
140
+
```html
141
+
<articleclass="listing-card featured">
142
+
<h1>Adorable 2BR in the sunny Mission</h1>
143
+
<p>Vestibulum id ligula porta felis euismod semper.</p>
144
+
</article>
145
+
```
146
+
147
+
```css
148
+
.listing-card { }
149
+
.listing-card.featured { }
150
+
.listing-cardh1 { }
151
+
.listing-cardp { }
152
+
```
153
+
142
154
### ID selectors
143
155
144
156
While it is possible to select elements by ID in CSS, it should generally be considered an anti-pattern. ID selectors introduce an unnecessarily high level of [specificity](https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity) to your rule declarations, and they are not reusable.
0 commit comments