Golang Tutorials - Learn Go Programming with Easy Step-by-Step Guides

Explore comprehensive Golang tutorials for beginners and advanced programmers. Learn Go programming with easy-to-follow, step-by-step guides, examples, and practical tips to master Go language quickly.

Pseudo Elements in CSS

Pseudo Elements in CSS

? Pseudo-elements in CSS

Pseudo-elements let you style specific parts of an element or insert content without adding extra HTML.

They use double colons :: followed by the pseudo-element name (single colon : also works but double colon is recommended).


Common Pseudo-elements

Pseudo-elementDescriptionExample
::beforeInserts content before the element’s actual contentAdds decorative icons, quotes
::afterInserts content after the element’s contentClearfix, decorative effects
::first-letterStyles the first letter of textDrop caps in paragraphs
::first-lineStyles the first line of textHighlight first line
::selectionStyles the part of text selected by the userChange highlight color

Basic Example

/* Add a quote before each blockquote */blockquote::before {  content: "“";  font-size: 2em;  color: gray;}/* Clear floats after a container */.container::after {  content: "";  display: table;  clear: both;}/* Style first letter like a drop cap */p::first-letter {  font-size: 2em;  font-weight: bold;  float: left;  margin-right: 5px;}

Important Notes

  • content property must be used with ::before and ::after.

  • Pseudo-elements are not part of the DOM, so you can’t target them with JavaScript directly.

  • Great for adding decorative elements without extra markup.


Want me to show you creative examples using pseudo-elements for buttons or fancy text effects?

Disclaimer for AI-Generated Content:
The content provided in these tutorials is generated using artificial intelligence and is intended for educational purposes only.
html
docker
php
kubernetes
golang
mysql
postgresql
mariaDB
sql