Consider another case more complex. We have a list of tags and leave the following HTML snippet:
<ul id="tags">
<li> CSS </li>
<li> content generation </li>
<li> pseudo-elements </li>
</Ul>
First, we align the presentation of different tags. We also take this opportunity to remove the bullets and the default margins elements li.
Code:
# Tags {
list-style: none;
}
# Tags li {
display: inline;
padding: 0;
margin: 0;
}
I hope that the list of tags to be identified as such. For this, we generate the text "Tags:" by applying it before the element ul , using the pseudo-element :before.
Code:
# Tags: before {
content: "tags \ 0000a0";
}
In addition, we want to distinguish the different tags by inserting a printable character (eg a dash) flanked by two spaces. We generate the whole before each element li , resulting in CSS:
Code:
# Tags li: before {
content: "-";
}
Each tag is thus preceded by a hyphen, including the first. In the latter case, the generation of content gives a result rather ugly ("Tags: - CSS"). Fortunately, it is possible to cancel the application generated content, and for this, we select the first element li using the pseudo-class :first-child , which can combine with other pseudo-classes and pseudo-elements. As for property content, we use it again, this time with the value none.
Code:
# Tags li: first-child: before {
content: none;
}
Bookmarks