-
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 syntax is the way we write rules to style HTML elements. Each rule consists of:
A Selector – targets the HTML element.
A Declaration Block – contains one or more declarations inside curly braces {}
.
A Declaration – consists of a property and a value, separated by a colon :
.
selector {
property: value;
}
p {
color: red;
font-size: 18px;
}
p
is the selector.
color
and font-size
are properties.
red
and 18px
are values.
Declarations are separated by semicolons and wrapped in {}
.
CSS comments are used to explain the code. They are not displayed in the browser.
/* This is a CSS comment */
body {
background-color: lightblue;
}
Part | Example | Description |
---|---|---|
Selector | p |
Targets paragraph elements |
Property | color |
Style to apply |
Value | red |
Setting of the property |
Declaration | color: red; |
Full style instruction |
Rule | p { color: red; } |
Complete CSS rule |
Q1. Write a CSS rule to set the color of all <h1>
elements to red.
Q2. Write a CSS rule to change the background color of the <body>
to yellow.
Q3. Write a CSS rule to make all <p>
elements bold.
Q4. Write a CSS rule to assign 300px width to all <div>
elements.
Q5. Add a comment above a rule that styles <h2>
headings.
Q6. Write a CSS rule to set Arial font for the <body>
.
Q7. Write a CSS rule to center-align all <h3>
text.
Q8. Write a CSS rule to give 20px padding to all <div>
elements.
Q9. Write a CSS rule to set blue color and italic style for <p>
elements.
Q10. Write a CSS rule to set grey background and 18px font size to the <body>
.
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)