diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 47d5e1e..7e011f4 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -2,33 +2,32 @@
Please note that this project is released with a [Contributor Code of Conduct](CODE-OF-CONDUCT.md). By participating in this project you agree to abide by its terms.
-
-## Table of Contents
+## Contents
- [Adding to This List](#adding-to-this-list)
- [Updating Your Pull Request](#updating-your-pull-request)
-
## Adding to This List
Please ensure your pull request adheres to the following guidelines:
-* Search open and closed PRs to avoid duplicate suggestions.
-* Only submit CSS tips that you think would be useful to others. This implies each tip has enough succinct content to describe why it's useful.
-* Add your tip at the bottom of the [README](https://github.com/AllThingsSmitty/css-protips/blob/master/README.md) document. Add a link to your tip at the bottom of the table of contents.
-* Use [title-case](https://titlecaseconverter.com/).
-* Code formatting should follow standard [CSSLint](http://www.csslint.net) default settings, including:
- * Indent with two spaces
- * Use shorthand, e.g., `margin: 10px 10px 5px;`
- * Use double quotes, e.g., `background: url("logo.svg");`
- * Sort properties alphabetically
-* Make sure your text editor is set to remove trailing whitespace.
-* Check your spelling and grammar.
-* The PR should have a useful title.
+- Search open and closed PRs to avoid duplicate suggestions.
+- Only submit CSS tips that you think would be useful to others. This implies each tip has enough succinct content to describe why it's useful.
+- Add your tip at the bottom of the [README](https://github.com/AllThingsSmitty/css-protips/blob/master/README.md) document. Add a link to your tip at the bottom of the table of contents.
+- Use [title-case](https://titlecaseconverter.com/).
+- Code formatting should follow standard [CSSLint](http://www.csslint.net) default settings, including:
+ - Indent with two spaces
+ - Use shorthand, e.g., `margin: 10px 10px 0.5rem;`
+ - Use double quotes, e.g., `background: url("logo.svg");`
+ - Use leading zeros with numberic values, e.g., `padding: 0.75rem;`
+ - Sort properties alphabetically
+ - **Avoid letting your code formatter format other section of the README file.**
+- Make sure your text editor is set to remove trailing whitespace.
+- Check your spelling and grammar.
+- The PR should have a useful title.
Thank you for your suggestions!
-
## Updating Your Pull Request
-Sometimes a maintainer will ask you to edit your pull request before it's included. This is normally due to spelling errors or because your PR didn't match the above guidelines guidelines. [This write-up](https://github.com/RichardLitt/knowledge/blob/master/github/amending-a-commit-guide.md) covers the different ways you can change a pull request.
\ No newline at end of file
+Sometimes a maintainer will ask you to edit your pull request before it's included. This is normally due to spelling errors or because your PR didn't match the above guidelines. [This write-up](https://github.com/RichardLitt/knowledge/blob/master/github/amending-a-commit-guide.md) covers the different ways you can change a pull request.
diff --git a/README.md b/README.md
index a6353d9..514038b 100644
--- a/README.md
+++ b/README.md
@@ -2,20 +2,19 @@
-# CSS Protips [](https://github.com/sindresorhus/awesome)
+# CSS Protips [](https://awesome.re)
A collection of tips to help take your CSS skills pro.
+> [!TIP]
> For other great lists check out [@sindresorhus](https://github.com/sindresorhus/)'s curated list of [awesome lists](https://github.com/sindresorhus/awesome/).
+## Contents
-## Table of Contents
-
-* [Protips](#protips)
-* [Support](#support)
-* [Translations](#translations)
-* [Contribution Guidelines](CONTRIBUTING.md)
-
+- [Protips](#protips)
+- [Support](#support)
+- [Translations](#translations)
+- [Contribution Guidelines](CONTRIBUTING.md)
## Protips
@@ -47,7 +46,7 @@ A collection of tips to help take your CSS skills pro.
1. [Use Pointer Events to Control Mouse Events](#use-pointer-events-to-control-mouse-events)
1. [Set `display: none` on Line Breaks Used as Spacing](#set-display-none-on-line-breaks-used-as-spacing)
1. [Use `:empty` to Hide Empty HTML Elements](#use-empty-to-hide-empty-html-elements)
-
+1. [Use `margin-inline` instead of `margin`](#use-margin-inline-instead-of-margin)
### Use a CSS Reset
@@ -68,10 +67,9 @@ Now elements will be stripped of margins and padding, and `box-sizing` lets you
#### [Demo](https://codepen.io/AllThingsSmitty/pen/kkrkLL)
> [!TIP]
-> If you follow the [Inherit `box-sizing`](#inherit-box-sizing) tip below you might opt to not include the `box-sizing` property in your CSS reset.
-
-[back to table of contents](#table-of-contents)
+> If you follow the [Inherit `box-sizing`](#inherit-box-sizing) tip below you might opt to not include the `box-sizing` property in your CSS reset.
+[Back to top](#contents)
### Inherit `box-sizing`
@@ -93,8 +91,7 @@ This makes it easier to change `box-sizing` in plugins or other components that
#### [Demo](https://css-tricks.com/inheriting-box-sizing-probably-slightly-better-best-practice/)
-[back to table of contents](#table-of-contents)
-
+[Back to top](#contents)
### Use `unset` Instead of Resetting All Properties
@@ -119,8 +116,7 @@ button {
}
```
-[back to table of contents](#table-of-contents)
-
+[Back to top](#contents)
### Use `:not()` to Apply/Unapply Borders on Navigation
@@ -154,8 +150,7 @@ Here, the CSS selector is read as a human would describe it.
#### [Demo](https://codepen.io/AllThingsSmitty/pen/LkymvO)
-[back to table of contents](#table-of-contents)
-
+[Back to top](#contents)
### Check if Font Is Installed Locally
@@ -165,12 +160,8 @@ You can check if a font is installed locally before fetching it remotely, which
@font-face {
font-family: "Dank Mono";
src:
- /* Full name */
- local("Dank Mono"),
- /* Postscript name */
- local("Dank Mono"),
- /* Otherwise, download it! */
- url("//...a.server/fonts/DankMono.woff");
+ /* Full name */ local("Dank Mono"), /* Postscript name */ local("Dank Mono"),
+ /* Otherwise, download it! */ url("//...a.server/fonts/DankMono.woff");
}
code {
@@ -180,8 +171,7 @@ code {
H/T to Adam Argyle for sharing this protip and [demo](https://codepen.io/argyleink/pen/VwYJpgR).
-[back to table of contents](#table-of-contents)
-
+[Back to top](#contents)
### Add `line-height` to `body`
@@ -197,8 +187,7 @@ This way textual elements can inherit from `body` easily.
#### [Demo](https://codepen.io/AllThingsSmitty/pen/VjbdYd)
-[back to table of contents](#table-of-contents)
-
+[Back to top](#contents)
### Set `:focus` for Form Elements
@@ -212,14 +201,13 @@ select:focus,
textarea:focus {
box-shadow: none;
outline: #000 dotted 2px;
- outline-offset: .05em;
+ outline-offset: 0.05em;
}
```
#### [Demo](https://codepen.io/AllThingsSmitty/pen/ePzoOP/)
-[back to table of contents](#table-of-contents)
-
+[Back to top](#contents)
### Vertically-Center Anything
@@ -253,8 +241,7 @@ body {
#### [Demo](https://codepen.io/AllThingsSmitty/pen/GqmGqZ)
-[back to table of contents](#table-of-contents)
-
+[Back to top](#contents)
### Use `aspect-ratio` Instead of Height/Width
@@ -271,8 +258,7 @@ Learn more about the `aspect-ratio` property in this [web.dev post](https://web.
#### [Demo](https://codepen.io/AllThingsSmitty/pen/MWxwoNx/)
-[back to table of contents](#table-of-contents)
-
+[Back to top](#contents)
### Comma-Separated Lists
@@ -289,8 +275,7 @@ Use the `:not()` pseudo-class and no comma will be added to the last item.
> [!NOTE]
> This tip may not be ideal for accessibility, specifically screen readers. And copy/paste from the browser doesn't work with CSS-generated content. Proceed with caution.
-[back to table of contents](#table-of-contents)
-
+[Back to top](#contents)
### Select Items Using Negative `nth-child`
@@ -302,7 +287,7 @@ li {
}
/* select items 1 through 3 and display them */
-li:nth-child(-n+3) {
+li:nth-child(-n + 3) {
display: block;
}
```
@@ -311,15 +296,14 @@ Or, since you've already learned a little about [using `:not()`](#use-not-to-app
```css
/* select all items except the first 3 and display them */
-li:not(:nth-child(-n+3)) {
+li:not(:nth-child(-n + 3)) {
display: block;
}
```
#### [Demo](https://codepen.io/AllThingsSmitty/pen/WxjKZp)
-[back to table of contents](#table-of-contents)
-
+[Back to top](#contents)
### Use SVG for Icons
@@ -342,8 +326,7 @@ SVG scales well for all resolution types and is supported in all browsers [back
}
```
-[back to table of contents](#table-of-contents)
-
+[Back to top](#contents)
### Use the "Lobotomized Owl" Selector
@@ -358,12 +341,11 @@ It may have a strange name but using the universal selector (`*`) with the adjac
In this example, all elements in the flow of the document that follow other elements will receive `margin-top: 1.5em`.
> [!TIP]
-> For more on the "lobotomized owl" selector, read [Heydon Pickering's post](http://alistapart.com/article/axiomatic-css-and-lobotomized-owls) on *A List Apart*.
+> For more on the "lobotomized owl" selector, read [Heydon Pickering's post](http://alistapart.com/article/axiomatic-css-and-lobotomized-owls) on _A List Apart_.
#### [Demo](https://codepen.io/AllThingsSmitty/pen/grRvWq)
-[back to table of contents](#table-of-contents)
-
+[Back to top](#contents)
### Use `max-height` for Pure CSS Sliders
@@ -384,8 +366,7 @@ Implement CSS-only sliders using `max-height` with overflow hidden:
The element expands to the `max-height` value on hover and the slider displays as a result of the overflow.
-[back to table of contents](#table-of-contents)
-
+[Back to top](#contents)
### Equal-Width Table Cells
@@ -401,8 +382,7 @@ Pain-free table layouts.
#### [Demo](https://codepen.io/AllThingsSmitty/pen/jALALm)
-[back to table of contents](#table-of-contents)
-
+[Back to top](#contents)
### Get Rid of Margin Hacks With Flexbox
@@ -421,8 +401,7 @@ When working with column gutters you can get rid of `nth-`, `first-`, and `last-
Now column gutters always appear evenly-spaced.
-[back to table of contents](#table-of-contents)
-
+[Back to top](#contents)
### Use Attribute Selectors with Empty Links
@@ -441,8 +420,7 @@ That's really convenient.
> [!NOTE]
> This tip may not be ideal for accessibility, specifically screen readers. And copy/paste from the browser doesn't work with CSS-generated content. Proceed with caution.
-[back to table of contents](#table-of-contents)
-
+[Back to top](#contents)
### Control Specificity Better with `:is()`
@@ -457,18 +435,37 @@ The `:is()` pseudo-class is used to target multiple selectors at once, reducing
The above ruleset is equivalent to the following number selector rules...
```css
-section h1, section h2, section h3, section h4, section h5, section h6,
-article h1, article h2, article h3, article h4, article h5, article h6,
-aside h1, aside h2, aside h3, aside h4, aside h5, aside h6,
-nav h1, nav h2, nav h3, nav h4, nav h5, nav h6 {
+section h1,
+section h2,
+section h3,
+section h4,
+section h5,
+section h6,
+article h1,
+article h2,
+article h3,
+article h4,
+article h5,
+article h6,
+aside h1,
+aside h2,
+aside h3,
+aside h4,
+aside h5,
+aside h6,
+nav h1,
+nav h2,
+nav h3,
+nav h4,
+nav h5,
+nav h6 {
color: green;
}
```
#### [Demo](https://codepen.io/AllThingsSmitty/pen/rNRVxdx)
-[back to table of contents](#table-of-contents)
-
+[Back to top](#contents)
### Style "Default" Links
@@ -483,8 +480,7 @@ a[href]:not([class]) {
Now links that are inserted via a CMS, which don't usually have a `class` attribute, will have a distinction without generically affecting the cascade.
-[back to table of contents](#table-of-contents)
-
+[Back to top](#contents)
### Intrinsic Ratio Boxes
@@ -511,8 +507,7 @@ Using 20% for padding makes the height of the box equal to 20% of its width. No
#### [Demo](https://codepen.io/AllThingsSmitty/pen/jALZvE)
-[back to table of contents](#table-of-contents)
-
+[Back to top](#contents)
### Style Broken Images
@@ -550,8 +545,7 @@ img::after {
> [!TIP]
> Learn more about styling for this pattern in [Ire Aderinokun's post](http://bitsofco.de/styling-broken-images/).
-[back to table of contents](#table-of-contents)
-
+[Back to top](#contents)
### Use `rem` for Global Sizing; Use `em` for Local Sizing
@@ -575,14 +569,13 @@ article {
}
aside .module {
- font-size: .9rem;
+ font-size: 0.9rem;
}
```
Now each module becomes compartmentalized and easier to style, more maintainable, and flexible.
-[back to table of contents](#table-of-contents)
-
+[Back to top](#contents)
### Hide Autoplay Videos That Aren't Muted
@@ -596,8 +589,7 @@ video[autoplay]:not([muted]) {
Once again, we're taking advantage of using the [`:not()`](#use-not-to-applyunapply-borders-on-navigation) pseudo-class.
-[back to table of contents](#table-of-contents)
-
+[Back to top](#contents)
### Use `:root` for Flexible Type
@@ -605,7 +597,7 @@ The type font size in a responsive layout should be able to adjust with each vie
```css
:root {
- font-size: calc(1vw + 1vh + .5vmin);
+ font-size: calc(1vw + 1vh + 0.5vmin);
}
```
@@ -619,8 +611,7 @@ body {
#### [Demo](https://codepen.io/AllThingsSmitty/pen/XKgOkR)
-[back to table of contents](#table-of-contents)
-
+[Back to top](#contents)
### Set `font-size` on Form Elements for a Better Mobile Experience
@@ -635,8 +626,7 @@ textarea {
}
```
-[back to table of contents](#table-of-contents)
-
+[Back to top](#contents)
### Use Pointer Events to Control Mouse Events
@@ -644,15 +634,14 @@ textarea {
```css
button:disabled {
- opacity: .5;
+ opacity: 0.5;
pointer-events: none;
}
```
It's that simple.
-[back to table of contents](#table-of-contents)
-
+[Back to top](#contents)
### Set `display: none` on Line Breaks Used as Spacing
@@ -664,12 +653,11 @@ br + br {
}
```
-[back to table of contents](#table-of-contents)
-
+[Back to top](#contents)
### Use `:empty` to Hide Empty HTML Elements
-If you have HTML elements that are empty, i.e., the content has yet to be set either by a CMS or dynamically injected (e.g., `