The CSS3 Pseudo-elements are used to change the style of the specific part of an HTML Element i.e if we want to change the first line of an HTML element this can be done easily by pseudo-elements.
Here is a simple example of a pseudo-element.
<style>
/*Pseudo Element Example*/
element-selector::pseudo-element {
property: value;
}
</style>
<head>
<style>
div::first-letter {
color: red;
font-size: 50px;
}
</style>
</head>
<body>
<div>TDB-School</div>
</body>
Here is a simple example of a pseudo-element.
<style>
/*Pseudo Element Example*/
div::first-line {
color: red;
font-size: 50px;
}
</style>
Note: We can apply ::first-line pseudo-element only on HTML block-level elements.
<head>
<style>
div::first-line {
color: red;
font-size: 50px;
}
</style>
</head>
<body>
<div>TDB-School<br> TDB-Tutorial</div>
</body>
We can also use multiple pseudo-elements on a single block-level HTML Tag.
<style>
div::first-letter {
color: red;}
div::first-line {
color: red;}
</style>
<style>
/*Pseudo Element Example*/
div::before {
content:"your text";
}
</style>
<head>
<style>
div::before {
content:"your text"
}
div::first-letter {
color: red;}
</style>
</head>
<body>
<div>TDB-School<br> TDB-Tutorial</div>
</body>