EN
CSS - mark text part with background color
0 points
In this article, we would like to show you how to mark text part with background color in CSS.
Quick solution:
CSS:
xxxxxxxxxx
1
.highlighted {
2
background: yellow;
3
}
HTML usage:
xxxxxxxxxx
1
<span class="highlighted">highlighted text...</span>
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.
xxxxxxxxxx
1
2
<html>
3
<head>
4
<style>
5
6
.highlighted {
7
background: yellow;
8
}
9
10
</style>
11
</head>
12
<body>
13
<div>Some text... <span class="highlighted">highlighted text...</span> some text...</div>
14
</body>
15
</html>