Languages
[Edit]
EN

CSS - mark text part with background color

0 points
Created by:
Ela-Davey
303

In this article, we would like to show you how to mark text part with background color in CSS.

Quick solution:

CSS:

.highlighted {
  background: yellow;
}

HTML usage:

<span class="highlighted">highlighted text...</span>

 

Practical example

In this example, we create a style for highlighted class to set its background color to yellow. Then in HTML page, we assign the highlighted class to the span element to color text within the element.

// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<head>
  <style>

    .highlighted {
      background: yellow;
    }

  </style>
</head>
<body>
  <div>Some text... <span class="highlighted">highlighted text...</span> some text...</div>
</body>
</html>
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join