html tutorial - How to change the default text selection color in the browsers using CSS - html5 - html code - html form



Answer: Use the CSS ::selection Pseudo-element

    You'll be able to override this setting with the CSS ::selection pseudo-element and With the most of the browsers highlights the chosen text in blue background.

    Currently browsers only support alittle subset of CSS properties for ::selection pseudo-element like color, background-color and text-shadow.

    Example

      ::selection {
          color: #fff;
          background: #87cefa;
          text-shadow: 1px 1px 2px #b040b0;
      }
      /* For Mozilla Firefox */
      ::-moz-selection {
          color: #fff;
          background: #87cefa;
          text-shadow: 1px 1px 2px #b040b0;
      }

      Related Searches to How to change the default text selection color in the browsers using CSS