Pseudo-classes and pseudo-elements are keywords used in CSS that allow you to style HTML elements based on their state or specific parts of an element.
Pseudo-classes are used to define the special states of an element. They allow you to style elements based on their interaction with users or their position in the document tree. Common examples include:
:hover
- Applies when the user hovers over an element.:focus
- Applies when an element has focus (such as a text input).:nth-child()
- Applies styles to elements based on their position in a parent.Pseudo-elements allow you to style specific parts of an element. They help in targeting sub-elements that are not directly accessible in the HTML. Examples include:
::before
- Inserts content before the content of an element.::after
- Inserts content after the content of an element.::first-line
- Styles the first line of a block element.
<style>
a:hover {
color: red;
}
p::first-line {
font-weight: bold;
}
</style>
<a href="#">Hover over me!</a>
<p>This is a paragraph that demonstrates the first line styling.</p>
How do I avoid rehashing overhead with std::set in multithreaded code?
How do I find elements with custom comparators with std::set for embedded targets?
How do I erase elements while iterating with std::set for embedded targets?
How do I provide stable iteration order with std::unordered_map for large datasets?
How do I reserve capacity ahead of time with std::unordered_map for large datasets?
How do I erase elements while iterating with std::unordered_map in multithreaded code?
How do I provide stable iteration order with std::map for embedded targets?
How do I provide stable iteration order with std::map in multithreaded code?
How do I avoid rehashing overhead with std::map in performance-sensitive code?
How do I merge two containers efficiently with std::map for embedded targets?