diff --git a/index.html b/index.html index b26ab9acb..09d5696eb 100644 --- a/index.html +++ b/index.html @@ -139,8 +139,12 @@

Changes the styling of text selection.

HTML

<p class="custom-text-selection">Select some of this text.</p>
 
-

CSS

.custom-text-selection::selection {
-  background: red;
+            

CSS

::selection {
+  background: aquamarine;
+  color: black;
+}
+.custom-text-selection::selection {
+  background: deeppink;
   color: white;
 }
 
@@ -150,16 +154,16 @@

Explanation

-

::selection defines a pseudo selector on an element to style text within it when selected.

+

::selection defines a pseudo selector on an element to style text within it when selected. Note that if you don't combine any other selector your style will be applied at document root level, to any selectable element.

Browser support

diff --git a/snippets/custom-text-selection.md b/snippets/custom-text-selection.md index c3cc6f1fb..ff5136934 100644 --- a/snippets/custom-text-selection.md +++ b/snippets/custom-text-selection.md @@ -11,8 +11,12 @@ Changes the styling of text selection. #### CSS ```css +::selection { + background: aquamarine; + color: black; +} .custom-text-selection::selection { - background: red; + background: deeppink; color: white; } ``` @@ -25,18 +29,18 @@ Changes the styling of text selection. #### Explanation -`::selection` defines a pseudo selector on an element to style text within it when selected. +`::selection` defines a pseudo selector on an element to style text within it when selected. Note that if you don't combine any other selector your style will be applied at document root level, to any selectable element. #### Browser support