Skip to content

Buzzingz

Unleashing the Power of Code

  • HTML
  • CSS
  • Toggle search form

CSS Pseudo-elements

Posted on March 15, 2023March 15, 2023 By shani No Comments on CSS Pseudo-elements

CSS Pseudo-elements are used to style specific parts of an element, such as the first letter, first line, or before/after content. Pseudo-elements are represented with a double colon (::) notation.

Some of the commonly used CSS Pseudo-elements are:

  1. ::before: This pseudo-element is used to insert content before the selected element.

Example:

p::before {
  content: "Before text";
}
  1. ::after: This pseudo-element is used to insert content after the selected element.

Example:

p::after {
  content: "After text";
}
  1. ::first-letter: This pseudo-element is used to select the first letter of the selected element.

Example:

p::first-letter {
  font-size: 200%;
}
  1. ::first-line: This pseudo-element is used to select the first line of the selected element.

Example:

p::first-line {
  font-weight: bold;
}
  1. ::selection: This pseudo-element is used to select the portion of the text that is currently being highlighted by the user.

Example:

::selection {
  background-color: yellow;
  color: black;
}

CSS Pseudo-elements can be used to add decorative or functional elements to a webpage without the need for extra HTML markup.

CSS

Post navigation

Previous Post: CSS Pseudo-classes
Next Post: CSS Opacity / Transparency

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

CSS Tutorial

  • Basic CSS Tutorial For Beginners
  • CSS Introduction
  • CSS Syntax
  • CSS Selectors
  • How To Add CSS
  • CSS Comments
  • CSS Colors
  • CSS Backgrounds
  • CSS Borders
  • CSS Margins
  • CSS Margin Collapse
  • CSS Padding
  • CSS Height, Width and Max-width
  • CSS Box Model
  • CSS Outline
  • CSS Text
  • CSS Fonts
  • CSS Web Safe Fonts
  • CSS Font Fallbacks
  • CSS Font Style
  • CSS Font Size
  • CSS Google Fonts
  • CSS Great Font Pairings
  • CSS Icons
  • CSS Links
  • CSS Lists
  • CSS Tables
  • CSS Layout – display: inline-block
  • CSS Layout – float and clear
  • CSS Layout – Horizontal & Vertical Align
  • CSS Layout – Overflow
  • CSS Layout – The display Property
  • CSS Layout – The z-index Property
  • CSS Layout – width and max-width
  • CSS Layout – The position Property
  • CSS Attribute Selectors
  • CSS Image Sprites
  • CSS Image Gallery
  • CSS Dropdowns
  • CSS Horizontal Navigation Bar
  • CSS Vertical Navigation Bar
  • CSS Navigation Bar
  • CSS Opacity / Transparency
  • CSS Pseudo-elements
  • CSS Pseudo-classes
  • CSS Combinators
  • CSS Math Functions
  • CSS The !important Rule
  • CSS Specificity
  • CSS Units
  • CSS Website Layout
  • CSS Counters
  • CSS Forms
  • About Us
  • Contact Us
  • Privacy Policy
  • Terms & Conditions

Copyright © 2023 Buzzingz.

Powered by PressBook WordPress theme