Skip to content

Commit c88e815

Browse files
authored
Update README.md
1 parent 3313c97 commit c88e815

File tree

1 file changed

+33
-21
lines changed

1 file changed

+33
-21
lines changed

README.md

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,15 @@ Finally, properties are what give the selected elements of a rule declaration th
6060

6161
### Formatting
6262

63-
* Use soft tabs (2 spaces) for indentation
63+
* Use soft tabs (2 spaces) for indentation.
6464
* 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.
6667
* 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.
6869
* 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.
7172

7273
**Bad**
7374

@@ -108,27 +109,20 @@ Finally, properties are what give the selected elements of a rule declaration th
108109

109110
### Naming Convention
110111

111-
**Example**
112-
113-
```jsx
114-
// ListingCard.jsx
115-
function ListingCard() {
116-
return (
117-
<article class="listing-card featured">
118-
119-
<h1 class="title">Adorable 2BR in the sunny Mission</h1>
112+
The naming convention is a simplified version of [BEM](http://getbem.com/naming/).
120113

121-
<div class="content">
122-
<p>Vestibulum id ligula porta felis euismod semper.</p>
123-
</div>
114+
**Example**
124115

125-
</article>
126-
);
127-
}
116+
```html
117+
<article class="listing-card featured">
118+
<h1 class="title">Adorable 2BR in the sunny Mission</h1>
119+
<div class="content">
120+
<p>Vestibulum id ligula porta felis euismod semper.</p>
121+
</div>
122+
</article>
128123
```
129124

130125
```css
131-
/* ListingCard.css */
132126
.listing-card { }
133127
.listing-card.featured { }
134128
.listing-card .title { }
@@ -139,6 +133,24 @@ function ListingCard() {
139133
* `.listing-card .title` is an “element” and represents a descendant of `.listing-card` that helps compose the block as a whole.
140134
* `.listing-card.featured` is a “modifier” and represents a different state or variation on the `.listing-card` block.
141135

136+
HTML tag names may be used instead of a class name to represent BEM-like elements.
137+
138+
**Example**
139+
140+
```html
141+
<article class="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-card h1 { }
151+
.listing-card p { }
152+
```
153+
142154
### ID selectors
143155

144156
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

Comments
 (0)