-
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 Combinators define relationships between elements. They allow you to target elements based on their structural relationship to other elements in the DOM.
There are 4 main types of CSS combinators:
Descendant (space
)
Child (>
)
Adjacent sibling (+
)
General sibling (~
)
A B
)Targets all B elements inside A, at any depth.
div p {
color: blue;
}
All
<p>
elements inside<div>
, including nested ones.
A > B
)Targets B elements that are direct children of A.
ul > li {
list-style-type: square;
}
Only
<li>
elements directly inside<ul>
(not deeper nested).
A + B
)Targets B element immediately after A, sharing the same parent.
h2 + p {
color: red;
}
Styles the first
<p>
that comes right after an<h2>
.
A ~ B
)Targets all B elements after A, sharing the same parent.
h2 ~ p {
font-style: italic;
}
All
<p>
elements that are siblings after an<h2>
.
Q1. Style all <p>
elements inside a <section>
.
Q2. Change color of direct <li>
children of a <ul>
.
Q3. Style a <p>
that comes right after any <h1>
.
Q4. Italicize all paragraphs after an <h2>
in a section.
Q5. Remove bullet from top-level <li>
only.
Q6. Change font of <span>
inside <div class="note">
.
Q7. Apply border to input elements that come directly after a <label>
.
Q8. Make all sibling <img>
tags after a <figure>
50% width.
Q9. Target only the first <p>
after a <div>
tag.
Q10. Apply underline to all <a>
tags that come after a <nav>
.
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)