-
Hajipur, Bihar, 844101
Hajipur, Bihar, 844101
CSS Basics
CSS Styling Properties
CSS Box Model
CSS Margin
CSS Padding
CSS Borders
CSS Outline
CSS Height/Width
CSS Max-width
CSS Display
CSS Position
CSS Z-index
CSS Overflow
CSS Float
CSS Inline-block
CSS Align
CSS Box Sizing
CSS Text
CSS Fonts
CSS Icons
CSS Text Effects
CSS Web Fonts
CSS Colors
CSS Backgrounds
CSS Color Keywords
CSS Gradients
CSS Shadows
CSS Links
CSS Lists
CSS Tables
CSS Advanced Selectors & Features
CSS Combinators
CSS Pseudo-classes
CSS Pseudo-elements
CSS Attribute Selectors
CSS Specificity
CSS !important
CSS Units
CSS Variables
CSS @property
CSS Math Functions
CSS Media and Image Styling
CSS Image Styling
CSS Image Centering
CSS Image Filters
CSS Image Shapes
CSS object-fit
CSS object-position
CSS Masking
CSS Layout Techniques
CSS Website Layout
CSS Navigation Bar
CSS Dropdowns
CSS Image Gallery
CSS Counters
CSS Pagination
CSS Multiple Columns
CSS User Interface
CSS Flexbox
CSS Grid
CSS Responsive Design (RWD)
CSS pseudo-elements allow you to style specific parts of an element without adding extra HTML tags. You can insert content, style specific letters or lines, and more.
selector::pseudo-element {
property: value;
}
Pseudo-element | Description |
---|---|
::before |
Inserts content before the element's content |
::after |
Inserts content after the element's content |
::first-letter |
Targets the first letter of text inside element |
::first-line |
Targets the first line of text |
::selection |
Styles text when highlighted by user |
::marker |
Styles bullets or numbers in lists (modern support) |
::before
Exampleh1::before {
content: "👉 ";
}
Adds content before <h1>
without changing the HTML.
::after
Examplep::after {
content: " ✔️";
color: green;
}
Adds a green checkmark after every <p>
.
::first-letter
Examplep::first-letter {
font-size: 2em;
font-weight: bold;
}
Enlarges the first letter of a paragraph (like in magazines).
::first-line
Examplep::first-line {
color: red;
}
Styles the first visible line of text in a paragraph.
::selection
Example::selection {
background-color: yellow;
color: black;
}
Applies when user selects/highlights text.
::marker
(for lists)ul li::marker {
color: red;
font-size: 20px;
}
Styles the bullet or number in a list.
💡
::before
and::after
requirecontent
property.
Q1. Add a star symbol before all <h2>
headings.
Q2. Insert a checkmark after each <li>
.
Q3. Style the first letter of a paragraph to be larger and bold.
Q4. Change color of first line in a <p>
to blue.
Q5. Highlight user-selected text with pink background.
Q6. Make bullets in <ul>
red and larger.
Q7. Append a copyright symbol after footer text.
Q8. Prefix "Note:" before every <blockquote>
.
Q9. Italicize only the first line of a quote.
Q10. Add an emoji after all links.
CSS Basics
CSS Styling Properties
CSS Box Model
CSS Margin
CSS Padding
CSS Borders
CSS Outline
CSS Height/Width
CSS Max-width
CSS Display
CSS Position
CSS Z-index
CSS Overflow
CSS Float
CSS Inline-block
CSS Align
CSS Box Sizing
CSS Text
CSS Fonts
CSS Icons
CSS Text Effects
CSS Web Fonts
CSS Colors
CSS Backgrounds
CSS Color Keywords
CSS Gradients
CSS Shadows
CSS Links
CSS Lists
CSS Tables
CSS Advanced Selectors & Features
CSS Combinators
CSS Pseudo-classes
CSS Pseudo-elements
CSS Attribute Selectors
CSS Specificity
CSS !important
CSS Units
CSS Variables
CSS @property
CSS Math Functions
CSS Media and Image Styling
CSS Image Styling
CSS Image Centering
CSS Image Filters
CSS Image Shapes
CSS object-fit
CSS object-position
CSS Masking
CSS Layout Techniques
CSS Website Layout
CSS Navigation Bar
CSS Dropdowns
CSS Image Gallery
CSS Counters
CSS Pagination
CSS Multiple Columns
CSS User Interface
CSS Flexbox
CSS Grid
CSS Responsive Design (RWD)