diff --git a/snippets/border-with-top-triangle.md b/snippets/border-with-top-triangle.md
index 4957b723e..361bb4591 100644
--- a/snippets/border-with-top-triangle.md
+++ b/snippets/border-with-top-triangle.md
@@ -9,10 +9,10 @@ lastUpdated: 2021-01-07T23:52:15+02:00
Creates a content container with a triangle at the top.
-- Use the `:before` and `:after` pseudo-elements to create two triangles.
+- Use the `::before` and `::after` pseudo-elements to create two triangles.
- The colors of the two triangles should be the same as the container's `border-color` and the container's `background-color` respectively.
-- The `border-width` of the one triangle (`:before`) should be `1px` wider than the other one (`:after`), in order to act as the border.
-- The smaller triangle (`:after`) should be `1px` to the right of the larger triangle (`:before`) to allow for its left border to be shown.
+- The `border-width` of the one triangle (`::before`) should be `1px` wider than the other one (`::after`), in order to act as the border.
+- The smaller triangle (`::after`) should be `1px` to the right of the larger triangle (`::before`) to allow for its left border to be shown.
```html
Border with top triangle
@@ -27,8 +27,8 @@ Creates a content container with a triangle at the top.
margin-top: 20px;
}
-.container:before,
-.container:after {
+.container::before,
+.container::after {
content: '';
position: absolute;
bottom: 100%;
@@ -37,7 +37,7 @@ Creates a content container with a triangle at the top.
border-bottom-color: #dddddd;
}
-.container:after {
+.container::after {
left: 20px;
border: 10px solid transparent;
border-bottom-color: #ffffff;
diff --git a/snippets/box-sizing-reset.md b/snippets/box-sizing-reset.md
index c39119615..3d8c4f9b1 100644
--- a/snippets/box-sizing-reset.md
+++ b/snippets/box-sizing-reset.md
@@ -23,8 +23,8 @@ div {
}
*,
-*:before,
-*:after {
+*::before,
+*::after {
box-sizing: inherit;
}
diff --git a/snippets/broken-image-fallback.md b/snippets/broken-image-fallback.md
index 59a376210..22d0d0794 100644
--- a/snippets/broken-image-fallback.md
+++ b/snippets/broken-image-fallback.md
@@ -11,7 +11,7 @@ firstSeen: 2022-11-04T05:00:00-04:00
Displays an error message when an image fails to load.
- Apply styles to the `img` element as if it was a text container.
-- Use the `:before` and `:after` pseudo-elements to display an error message and the image URL. These elements will only be displayed if the image fails to load.
+- Use the `::before` and `::after` pseudo-elements to display an error message and the image URL. These elements will only be displayed if the image fails to load.
```html
@@ -29,13 +29,13 @@ img {
width: 100%;
}
-img:before {
+img::before {
content: "Sorry, this image is unavailable.";
display: block;
margin-bottom: 8px;
}
-img:after {
+img::after {
content: "(url: " attr(src) ")";
display: block;
font-size: 12px;
diff --git a/snippets/button-border-animation.md b/snippets/button-border-animation.md
index 66f45fc42..7cd02cef1 100644
--- a/snippets/button-border-animation.md
+++ b/snippets/button-border-animation.md
@@ -9,7 +9,7 @@ lastUpdated: 2021-05-24T15:28:52+03:00
Creates a border animation on hover.
-- Use the `:before` and `:after` pseudo-elements to create two boxes `24px` wide opposite each other above and below the box.
+- Use the `::before` and `::after` pseudo-elements to create two boxes `24px` wide opposite each other above and below the box.
- Use the `:hover` pseudo-class to extend the `width` of those elements to `100%` on hover and animate the change using `transition`.
```html
@@ -26,8 +26,8 @@ Creates a border animation on hover.
position: relative;
}
-.animated-border-button:before,
-.animated-border-button:after {
+.animated-border-button::before,
+.animated-border-button::after {
border: 0 solid transparent;
transition: all 0.3s;
content: '';
@@ -36,20 +36,20 @@ Creates a border animation on hover.
width: 24px;
}
-.animated-border-button:before {
+.animated-border-button::before {
border-top: 2px solid #263059;
right: 0;
top: -4px;
}
-.animated-border-button:after {
+.animated-border-button::after {
border-bottom: 2px solid #263059;
bottom: -4px;
left: 0;
}
-.animated-border-button:hover:before,
-.animated-border-button:hover:after {
+.animated-border-button:hover::before,
+.animated-border-button:hover::after {
width: 100%;
}
```
diff --git a/snippets/clearfix.md b/snippets/clearfix.md
index 684de1e8e..a5d02de64 100644
--- a/snippets/clearfix.md
+++ b/snippets/clearfix.md
@@ -9,7 +9,7 @@ lastUpdated: 2020-12-30T15:37:37+02:00
Ensures that an element self-clears its children.
-- Use the `:after` pseudo-element and apply `content: ''` to allow it to affect layout.
+- Use the `::after` pseudo-element and apply `content: ''` to allow it to affect layout.
- Use `clear: both` to make the element clear past both left and right floats.
- For this technique to work properly, make sure there are no non-floating children in the container and that there are no tall floats before the clearfixed container but in the same formatting context (e.g. floated columns).
- **Note:** This is only useful if you are using `float` to build layouts. Consider using a more modern approach, such as the flexbox or grid layout.
@@ -23,7 +23,7 @@ Ensures that an element self-clears its children.
```
```css
-.clearfix:after {
+.clearfix::after {
content: '';
display: block;
clear: both;
diff --git a/snippets/constant-width-to-height-ratio.md b/snippets/constant-width-to-height-ratio.md
index fac07116f..8ddb5b9df 100644
--- a/snippets/constant-width-to-height-ratio.md
+++ b/snippets/constant-width-to-height-ratio.md
@@ -9,7 +9,7 @@ lastUpdated: 2020-12-30T15:37:37+02:00
Ensures that an element with variable `width` will retain a proportionate `height` value.
-- Apply `padding-top` on the `:before` pseudo-element, making the `height` of the element equal to a percentage of its `width`.
+- Apply `padding-top` on the `::before` pseudo-element, making the `height` of the element equal to a percentage of its `width`.
- The proportion of `height` to `width` can be altered as necessary. For example a `padding-top` of `100%` will create a responsive square (1:1 ratio).
```html
@@ -22,13 +22,13 @@ Ensures that an element with variable `width` will retain a proportionate `heigh
width: 50%;
}
-.constant-width-to-height-ratio:before {
+.constant-width-to-height-ratio::before {
content: '';
padding-top: 100%;
float: left;
}
-.constant-width-to-height-ratio:after {
+.constant-width-to-height-ratio::after {
content: '';
display: block;
clear: both;
diff --git a/snippets/counter.md b/snippets/counter.md
index 12f50e230..58ecff9b0 100644
--- a/snippets/counter.md
+++ b/snippets/counter.md
@@ -11,7 +11,7 @@ Creates a custom list counter that accounts for nested list elements.
- Use `counter-reset` to initialize a variable counter (default `0`), the name of which is the value of the attribute (i.e. `counter`).
- Use `counter-increment` on the variable counter for each countable element (i.e. each `
`).
-- Use `counters()` to display the value of each variable counter as part of the `content` of the `:before` pseudo-element for each countable element (i.e. each `
`). The second value passed to it (`'.'`) acts as the delimiter for nested counters.
+- Use `counters()` to display the value of each variable counter as part of the `content` of the `::before` pseudo-element for each countable element (i.e. each `
`). The second value passed to it (`'.'`) acts as the delimiter for nested counters.
```html
@@ -34,7 +34,7 @@ ul {
list-style: none;
}
-li:before {
+li::before {
counter-increment: counter;
content: counters(counter, '.') ' ';
}
diff --git a/snippets/custom-radio.md b/snippets/custom-radio.md
index b1385f2cf..fb149ffca 100644
--- a/snippets/custom-radio.md
+++ b/snippets/custom-radio.md
@@ -11,7 +11,7 @@ Creates a styled radio button with animation on state change.
- Create a `.radio-container` and use flexbox to create the appropriate layout for the radio buttons.
- Reset the styles on the `` and use it to create the outline and background of the radio button.
-- Use the `:before` element to create the inner circle of the radio button.
+- Use the `::before` element to create the inner circle of the radio button.
- Use `transform: scale(1)` and a CSS transition to create an animation effect on state change.
```html
@@ -53,7 +53,7 @@ Creates a styled radio button with animation on state change.
transition: all 0.3s ease;
}
-.radio-input:before {
+.radio-input::before {
content: "";
width: 6px;
height: 6px;
@@ -68,7 +68,7 @@ Creates a styled radio button with animation on state change.
border-color: #0077ff;
}
-.radio-input:checked:before {
+.radio-input:checked::before {
transform: scale(1);
}
diff --git a/snippets/display-empty-links.md b/snippets/display-empty-links.md
index 0215ed0ec..44290a27e 100644
--- a/snippets/display-empty-links.md
+++ b/snippets/display-empty-links.md
@@ -11,14 +11,14 @@ Displays the link URL for links with no text.
- Use the `:empty` pseudo-class to select links with no text.
- Use the `:not` pseudo-class to exclude links with text.
-- Use the `content` property and the `attr()` function to display the link URL in the `:before` pseudo-element.
+- Use the `content` property and the `attr()` function to display the link URL in the `::before` pseudo-element.
```html
```
```css
-a[href^="http"]:empty:before {
+a[href^="http"]:empty::before {
content: attr(href);
}
```
diff --git a/snippets/dynamic-shadow.md b/snippets/dynamic-shadow.md
index 109553054..73f171428 100644
--- a/snippets/dynamic-shadow.md
+++ b/snippets/dynamic-shadow.md
@@ -9,7 +9,7 @@ lastUpdated: 2020-12-30T15:37:37+02:00
Creates a shadow similar to `box-shadow` but based on the colors of the element itself.
-- Use the `:after` pseudo-element with `position: absolute` and `width` and `height` equal to `100%` to fill the available space in the parent element.
+- Use the `::after` pseudo-element with `position: absolute` and `width` and `height` equal to `100%` to fill the available space in the parent element.
- Use `background: inherit` to inherit the `background` of the parent element.
- Use `top` to slightly offset the pseudo-element, `filter: blur()` to create a shadow and `opacity` to make it semi-transparent.
- Use `z-index: 1` on the parent and `z-index: -1` on the pseudo-element to position it behind its parent.
@@ -27,7 +27,7 @@ Creates a shadow similar to `box-shadow` but based on the colors of the element
z-index: 1;
}
-.dynamic-shadow:after {
+.dynamic-shadow::after {
content: '';
width: 100%;
height: 100%;
diff --git a/snippets/hover-underline-animation.md b/snippets/hover-underline-animation.md
index c63b3e600..c2455d0fa 100644
--- a/snippets/hover-underline-animation.md
+++ b/snippets/hover-underline-animation.md
@@ -10,7 +10,7 @@ lastUpdated: 2021-10-11T18:44:51+03:00
Creates an animated underline effect when the user hovers over the text.
- Use `display: inline-block` to make the underline span just the width of the text content.
-- Use the `:after` pseudo-element with `width: 100%` and `position: absolute` to place it below the content.
+- Use the `::after` pseudo-element with `width: 100%` and `position: absolute` to place it below the content.
- Use `transform: scaleX(0)` to initially hide the pseudo-element.
- Use the `:hover` pseudo-class selector to apply `transform: scaleX(1)` and display the pseudo-element on hover.
- Animate `transform` using `transform-origin: left` and an appropriate `transition`.
@@ -27,7 +27,7 @@ Creates an animated underline effect when the user hovers over the text.
color: #0087ca;
}
-.hover-underline-animation:after {
+.hover-underline-animation::after {
content: '';
position: absolute;
width: 100%;
@@ -40,7 +40,7 @@ Creates an animated underline effect when the user hovers over the text.
transition: transform 0.25s ease-out;
}
-.hover-underline-animation:hover:after {
+.hover-underline-animation:hover::after {
transform: scaleX(1);
transform-origin: bottom left;
}
diff --git a/snippets/image-overlay-hover.md b/snippets/image-overlay-hover.md
index aee886862..34d47afcc 100644
--- a/snippets/image-overlay-hover.md
+++ b/snippets/image-overlay-hover.md
@@ -9,7 +9,7 @@ lastUpdated: 2021-10-11T18:44:51+03:00
Displays an image overlay effect on hover.
-- Use the `:before` and `:after` pseudo-elements for the top and bottom bars of the overlay respectively. Set their `opacity`, `transform` and `transition` to produce the desired effect.
+- Use the `::before` and `::after` pseudo-elements for the top and bottom bars of the overlay respectively. Set their `opacity`, `transform` and `transition` to produce the desired effect.
- Use the `` for the text of the overlay. Set `display: flex`, `flex-direction: column` and `justify-content: center` to center the text into the image.
- Use the `:hover` pseudo-selector to update the `opacity` and `transform` of all the elements and display the overlay.
@@ -41,8 +41,8 @@ Displays an image overlay effect on hover.
transition: all 0.45s ease;
}
-.hover-img:before,
-.hover-img:after {
+.hover-img::before,
+.hover-img::after {
background-color: rgba(0, 0, 0, 0.5);
border-top: 32px solid rgba(0, 0, 0, 0.5);
border-bottom: 32px solid rgba(0, 0, 0, 0.5);
@@ -86,8 +86,8 @@ Displays an image overlay effect on hover.
text-transform: uppercase;
}
-.hover-img:hover:before,
-.hover-img:hover:after {
+.hover-img:hover::before,
+.hover-img:hover::after {
transform: scale(1);
opacity: 1;
}
diff --git a/snippets/mouse-cursor-gradient-tracking.md b/snippets/mouse-cursor-gradient-tracking.md
index 1a0df6630..483e41f02 100644
--- a/snippets/mouse-cursor-gradient-tracking.md
+++ b/snippets/mouse-cursor-gradient-tracking.md
@@ -38,7 +38,7 @@ A hover effect where the gradient follows the mouse cursor.
position: relative;
}
-.mouse-cursor-gradient-tracking:before {
+.mouse-cursor-gradient-tracking::before {
--size: 0;
content: '';
position: absolute;
@@ -51,7 +51,7 @@ A hover effect where the gradient follows the mouse cursor.
transition: width 0.2s ease, height 0.2s ease;
}
-.mouse-cursor-gradient-tracking:hover:before {
+.mouse-cursor-gradient-tracking:hover::before {
--size: 200px;
}
```
diff --git a/snippets/navigation-list-item-hover-and-focus-effect.md b/snippets/navigation-list-item-hover-and-focus-effect.md
index 735d39d5a..a03650e55 100644
--- a/snippets/navigation-list-item-hover-and-focus-effect.md
+++ b/snippets/navigation-list-item-hover-and-focus-effect.md
@@ -9,7 +9,7 @@ lastUpdated: 2021-10-11T18:44:51+03:00
Creates a custom hover and focus effect for navigation items, using CSS transformations.
-- Use the `:before` pseudo-element at the list item anchor to create a hover effect. Hide it using `transform: scale(0)`.
+- Use the `::before` pseudo-element at the list item anchor to create a hover effect. Hide it using `transform: scale(0)`.
- Use the `:hover` and `:focus` pseudo-class selectors to transition the pseudo-element to `transform: scale(1)` and show its colored background.
- Prevent the pseudo-element from covering the anchor element by using `z-index`.
@@ -45,7 +45,7 @@ Creates a custom hover and focus effect for navigation items, using CSS transfor
z-index: 0;
}
-li a:before {
+li a::before {
position: absolute;
content: "";
width: 100%;
@@ -58,8 +58,8 @@ li a:before {
transition: transform 0.5s ease-in-out;
}
-li a:hover:before,
-li a:focus:before {
+li a:hover::before,
+li a:focus::before {
transform: scale(1);
}
```
diff --git a/snippets/overflow-scroll-gradient.md b/snippets/overflow-scroll-gradient.md
index 61de8bc4e..1b3553010 100644
--- a/snippets/overflow-scroll-gradient.md
+++ b/snippets/overflow-scroll-gradient.md
@@ -9,7 +9,7 @@ lastUpdated: 2021-10-13T19:29:39+02:00
Adds a fading gradient to an overflowing element to better indicate there is more content to be scrolled.
-- Use the `:after` pseudo-element to create a `linear-gradient()` that fades from `transparent` to `white` (top to bottom).
+- Use the `::after` pseudo-element to create a `linear-gradient()` that fades from `transparent` to `white` (top to bottom).
- Use `position: absolute`, `width` and `height` to place and size the pseudo-element in its parent.
- Use `pointer-events: none` to exclude the pseudo-element from mouse events, allowing text behind it to still be selectable/interactive.
@@ -33,7 +33,7 @@ Adds a fading gradient to an overflowing element to better indicate there is mor
position: relative;
}
-.overflow-scroll-gradient:after {
+.overflow-scroll-gradient::after {
content: '';
position: absolute;
bottom: 0;
diff --git a/snippets/shape-separator.md b/snippets/shape-separator.md
index 5fb417668..470277b10 100644
--- a/snippets/shape-separator.md
+++ b/snippets/shape-separator.md
@@ -10,7 +10,7 @@ lastUpdated: 2021-01-04T12:30:40+02:00
Uses an SVG shape to create a separator between two different blocks.
-- Use the `:after` pseudo-element to create the separator element.
+- Use the `::after` pseudo-element to create the separator element.
- Use `background-image` to add the SVG (a 24x12 triangle) shape via a data URI. The background image will repeat by default, covering the whole area of the pseudo-element.
- Use the `background` of the parent element to set the desired color for the separator.
@@ -25,7 +25,7 @@ Uses an SVG shape to create a separator between two different blocks.
background: #9C27B0;
}
-.shape-separator:after {
+.shape-separator::after {
content: '';
background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 12'%3E%3Cpath d='m12 0l12 12h-24z' fill='transparent'/%3E%3C/svg%3E");
position: absolute;
diff --git a/snippets/toggle-switch.md b/snippets/toggle-switch.md
index dfcf063c3..000aa79bf 100644
--- a/snippets/toggle-switch.md
+++ b/snippets/toggle-switch.md
@@ -10,7 +10,7 @@ lastUpdated: 2020-12-30T15:37:37+02:00
Creates a toggle switch with CSS only.
- Use the `for` attribute to associate the `