Skip to content

Commit fda73a2

Browse files
authored
Update unordered list and list items to markdown format
1 parent 95a2e9a commit fda73a2

1 file changed

Lines changed: 54 additions & 59 deletions

File tree

  • wordpress-coding-standards

wordpress-coding-standards/css.md

Lines changed: 54 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ Within core stylesheets, inconsistencies will often be found. We are working on
77
## Structure
88

99
There are plenty of different methods for structuring a stylesheet. With the CSS in core, it is important to retain a high degree of legibility. This enables subsequent contributors to have a clear understanding of the flow of the document.
10-
<ul>
11-
<li>Use tabs, not spaces, to indent each property.</li>
12-
<li>Add two blank lines between sections and one blank line between blocks in a section.</li>
13-
<li>Each selector should be on its own line, ending in either a comma or an opening curly brace. Property-value pairs should be on their own line, with one tab of indentation and an ending semicolon. The closing brace should be flush left, using the same level of indentation as the opening selector.</li>
14-
</ul>
10+
11+
- Use tabs, not spaces, to indent each property.
12+
- Add two blank lines between sections and one blank line between blocks in a section.
13+
- Each selector should be on its own line, ending in either a comma or an opening curly brace. Property-value pairs should be on their own line, with one tab of indentation and an ending semicolon. The closing brace should be flush left, using the same level of indentation as the opening selector.
14+
1515
Correct:
1616

1717
```css
@@ -37,12 +37,12 @@ Incorrect:
3737
## Selectors
3838

3939
With specificity, comes great responsibility. Broad selectors allow us to be efficient, yet can have adverse consequences if not tested. Location-specific selectors can save us time, but will quickly lead to a cluttered stylesheet. Exercise your best judgement to create selectors that find the right balance between contributing to the overall style and layout of the DOM.
40-
<ul>
41-
<li>Similar to the <a href="https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#naming-conventions">WordPress PHP Coding Standards</a> for file names, use lowercase and separate words with hyphens when naming selectors. Avoid camelcase and underscores.</li>
42-
<li>Use human readable selectors that describe what element(s) they style.</li>
43-
<li>Attribute selectors should use double quotes around values</li>
44-
<li>Refrain from using over-qualified selectors, <code>div.container</code> can simply be stated as <code>.container</code></li>
45-
</ul>
40+
41+
- Similar to the <a href="https://developer.wordpress.org/coding-standards/wordpress-coding-standards/php/#naming-conventions">WordPress PHP Coding Standards</a> for file names, use lowercase and separate words with hyphens when naming selectors. Avoid camelcase and underscores.
42+
- Use human readable selectors that describe what element(s) they style.
43+
- Attribute selectors should use double quotes around values
44+
- Refrain from using over-qualified selectors, <code>div.container</code> can simply be stated as <code>.container</code>
45+
4646
Correct:
4747

4848
```css
@@ -82,12 +82,12 @@ input[type=text] { /&042; Should be [type="text"] &042;/
8282
## Properties
8383

8484
Similar to selectors, properties that are too specific will hinder the flexibility of the design. Less is more. Make sure you are not repeating styling or introducing fixed dimensions (when a fluid solution is more acceptable).
85-
<ul>
86-
<li>Properties should be followed by a colon and a space.</li>
87-
<li>All properties and values should be lowercase, except for font names and vendor-specific properties.</li>
88-
<li>Use hex code for colors, or rgba() if opacity is needed. Avoid RGB format and uppercase, and shorten values when possible: <code>#fff</code> instead of <code>#FFFFFF</code>.</li>
89-
<li>Use shorthand (except when overriding styles) for background, border, font, list-style, margin, and padding values as much as possible. (For a shorthand reference, see <a href="https://codex.wordpress.org/CSS_Shorthand">CSS Shorthand</a>.)</li>
90-
</ul>
85+
86+
- Properties should be followed by a colon and a space.
87+
- All properties and values should be lowercase, except for font names and vendor-specific properties.
88+
- Use hex code for colors, or rgba() if opacity is needed. Avoid RGB format and uppercase, and shorten values when possible: <code>#fff</code> instead of <code>#FFFFFF</code>.
89+
- Use shorthand (except when overriding styles) for background, border, font, list-style, margin, and padding values as much as possible. (For a shorthand reference, see <a href="https://codex.wordpress.org/CSS_Shorthand">CSS Shorthand</a>.)
90+
9191
Correct:
9292

9393
```css
@@ -114,14 +114,15 @@ Incorrect:
114114

115115
<blockquote>"Group like properties together, especially if you have a lot of them."
116116
-- Nacin</blockquote>
117+
117118
Above all else, choose something that is meaningful to you and semantic in some way. Random ordering is chaos, not poetry. In WordPress Core, our choice is logical or grouped ordering, wherein properties are grouped by meaning and ordered specifically within those groups. The properties within groups are also strategically ordered to create transitions between sections, such as background directly before color. The baseline for ordering is:
118-
<ul>
119-
<li>Display</li>
120-
<li>Positioning</li>
121-
<li>Box model</li>
122-
<li>Colors and Typography</li>
123-
<li>Other</li>
124-
</ul>
119+
120+
- Display
121+
- Positioning
122+
- Box model
123+
- Colors and Typography
124+
- Other
125+
125126
Things that are not yet used in core itself, such as CSS3 animations, may not have a prescribed place above but likely would fit into one of the above in a logical manner. Just as CSS is evolving, so our standards will evolve with it.
126127

127128
Top/Right/Bottom/Left (TRBL/trouble) should be the order for any relevant properties (e.g. margin), much as the order goes in values. Corner specifiers (e.g. border-radius-*-*) should be top-left, top-right, bottom-right, bottom-left. This is derived from how shorthand values would be ordered.
@@ -169,18 +170,18 @@ We use <a href="https://github.com/postcss/autoprefixer">Autoprefixer</a> as a p
169170
## Values
170171

171172
There are numerous ways to input values for properties. Follow the guidelines below to help us retain a high degree of consistency.
172-
<ul>
173-
<li>Space before the value, after the colon.</li>
174-
<li>Do not pad parentheses with spaces.</li>
175-
<li>Always end in a semicolon.</li>
176-
<li>Use double quotes rather than single quotes, and only when needed, such as when a font name has a space or for the values of the <code>content</code> property.</li>
177-
<li>Font weights should be defined using numeric values (e.g. <code>400</code> instead of <code>normal</code>, <code>700</code> rather than <code>bold</code>).</li>
178-
<li>0 values should not have units unless necessary, such as with transition-duration.</li>
179-
<li>Line height should also be unit-less, unless necessary to be defined as a specific pixel value. This is more than just a style convention, but is worth mentioning here. More information: <a href="http://meyerweb.com/eric/thoughts/2006/02/08/unitless-line-heights/">http://meyerweb.com/eric/thoughts/2006/02/08/unitless-line-heights/</a></li>
180-
<li>Use a leading zero for decimal values, including in rgba().</li>
181-
<li>Multiple comma-separated values for one property should be separated by either a space or a newline. For better readability newlines should be used for lengthier multi-part values such as those for shorthand properties like box-shadow and text-shadow, including before the first value. Values should then be indented one level in from the property.</li>
182-
<li>Lists of values within a value, like within rgba(), should be separated by a space.</li>
183-
</ul>
173+
174+
- Space before the value, after the colon.
175+
- Do not pad parentheses with spaces.
176+
- Always end in a semicolon.
177+
- Use double quotes rather than single quotes, and only when needed, such as when a font name has a space or for the values of the <code>content</code> property.
178+
- Font weights should be defined using numeric values (e.g. <code>400</code> instead of <code>normal</code>, <code>700</code> rather than <code>bold</code>).
179+
- 0 values should not have units unless necessary, such as with transition-duration.
180+
- Line height should also be unit-less, unless necessary to be defined as a specific pixel value. This is more than just a style convention, but is worth mentioning here. More information: <a href="http://meyerweb.com/eric/thoughts/2006/02/08/unitless-line-heights/">http://meyerweb.com/eric/thoughts/2006/02/08/unitless-line-heights/</a>
181+
- Use a leading zero for decimal values, including in rgba().
182+
- Multiple comma-separated values for one property should be separated by either a space or a newline. For better readability newlines should be used for lengthier multi-part values such as those for shorthand properties like box-shadow and text-shadow, including before the first value. Values should then be indented one level in from the property.
183+
- Lists of values within a value, like within rgba(), should be separated by a space.
184+
184185
Correct:
185186

186187
```css
@@ -236,14 +237,11 @@ Incorrect:
236237
## Media Queries
237238

238239
Media queries allow us to gracefully degrade the DOM for different screen sizes. If you are adding any, be sure to test above and below the break-point you are targeting.
239-
<ul>
240-
<li>It is generally advisable to keep media queries grouped by media at the bottom of the stylesheet.
241-
<ul>
242-
<li>An exception is made for the wp-admin.css file in core, as it is very large and each section essentially represents a stylesheet of its own. Media queries are therefore added at the bottom of sections as applicable.</li>
243-
</ul>
244-
</li>
245-
<li>Rule sets for media queries should be indented one level in.</li>
246-
</ul>
240+
241+
- It is generally advisable to keep media queries grouped by media at the bottom of the stylesheet.
242+
- An exception is made for the wp-admin.css file in core, as it is very large and each section essentially represents a stylesheet of its own. Media queries are therefore added at the bottom of sections as applicable.
243+
- Rule sets for media queries should be indented one level in.
244+
247245
Example:
248246

249247
```css
@@ -254,11 +252,10 @@ Example:
254252

255253
## Commenting
256254

257-
<ul>
258-
<li>Comment, and comment liberally. If there are concerns about file size, utilize minified files and the SCRIPT_DEBUG constant. Long comments should manually break the line length at 80 characters.</li>
259-
<li>A table of contents should be utilized for longer stylesheets, especially those that are highly sectioned. Using an index number (1.0, 1.1, 2.0, etc.) aids in searching and jumping to a location.</li>
260-
<li>Comments should be formatted much as PHPDoc is. The <a href="http://web.archive.org/web/20070601200419/http://cssdoc.net/">CSSDoc</a> standard is not necessarily widely accepted or used but some aspects of it may be adopted over time. Section/subsection headers should have newlines before and after. Inline comments should not have empty newlines separating the comment from the item to which it relates.</li>
261-
</ul>
255+
- Comment, and comment liberally. If there are concerns about file size, utilize minified files and the SCRIPT_DEBUG constant. Long comments should manually break the line length at 80 characters.
256+
- A table of contents should be utilized for longer stylesheets, especially those that are highly sectioned. Using an index number (1.0, 1.1, 2.0, etc.) aids in searching and jumping to a location.
257+
- Comments should be formatted much as PHPDoc is. The <a href="http://web.archive.org/web/20070601200419/http://cssdoc.net/">CSSDoc</a> standard is not necessarily widely accepted or used but some aspects of it may be adopted over time. Section/subsection headers should have newlines before and after. Inline comments should not have empty newlines separating the comment from the item to which it relates.
258+
262259
For sections and subsections:
263260

264261
```css
@@ -286,20 +283,18 @@ For inline:
286283
## Best Practices
287284

288285
Stylesheets tend to grow in length and complexity, and as they grow the chance of redundancy increases. By following some best practices we can help our CSS maintain focus and flexibility as it evolves:
289-
<ul>
290-
<li>If you are attempting to fix an issue, attempt to remove code before adding more.</li>
291-
<li>Magic Numbers are unlucky. These are numbers that are used as quick fixes on a one-off basis. Example: <code>.box { margin-top: 37px }</code>.</li>
292-
<li>DOM will change over time, target the element you want to use as opposed to "finding it" through its parents. Example: Use <code>.highlight</code> on the element as opposed to <code>.highlight a</code> (where the selector is on the parent)</li>
293-
<li>Know when to use the height property. It should be used when you are including outside elements (such as images). Otherwise use line-height for more flexibility.</li>
294-
<li>Do not restate default property &amp; value combinations (for instance <code>display: block;</code> on block-level elements).</li>
295-
</ul>
286+
287+
- If you are attempting to fix an issue, attempt to remove code before adding more.
288+
- Magic Numbers are unlucky. These are numbers that are used as quick fixes on a one-off basis. Example: <code>.box { margin-top: 37px }</code>.
289+
- DOM will change over time, target the element you want to use as opposed to "finding it" through its parents. Example: Use <code>.highlight</code> on the element as opposed to <code>.highlight a</code> (where the selector is on the parent)
290+
- Know when to use the height property. It should be used when you are including outside elements (such as images). Otherwise use line-height for more flexibility.
291+
- Do not restate default property &amp; value combinations (for instance <code>display: block;</code> on block-level elements).
292+
296293

297294
### WP Admin CSS
298295

299296
Check out the <a href="https://wordpress.github.io/css-audit/public/wp-admin">WP Admin CSS Audit</a>, a report generated to document the health of the WP Admin CSS code. Read more in <a href="https://github.com/WordPress/css-audit/blob/trunk/README.md">the repository's README</a>.
300297

301298
## Related Links
302299

303-
<ul>
304-
<li>Principles of writing consistent, idiomatic CSS: <a href="https://github.com/necolas/idiomatic-css">https://github.com/necolas/idiomatic-css</a></li>
305-
</ul>
300+
- Principles of writing consistent, idiomatic CSS: <a href="https://github.com/necolas/idiomatic-css">https://github.com/necolas/idiomatic-css</a>

0 commit comments

Comments
 (0)