codegurukool.com · Free coding tutorials & online compiler

Home › CSS Tutorial › Pseudo-elements

Pseudo-elements

Style part of an element.

::before and ::after insert generated content. ::first-line, ::first-letter and ::selection style parts of text.

Example code

<style>
p::first-letter{font-size:2.4em;color:crimson}
.t::after{content:' (new)';color:green}
::selection{background:gold}
</style>
<p>Drop-cap paragraph. Select me.</p><p class='t'>Title</p>

Run this code in the online editor

← Pseudo-classesCSS opacity →