-
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)
Every HTML element can be considered as a box in CSS. The CSS Box Model describes how these boxes are rendered and how space is added around elements.
The box model consists of the following areas:
Content – The actual text or image inside the element
Padding – Space between the content and the border
Border – The outline surrounding the padding
Margin – Space outside the border, between this and other elements
| Margin |
| --------- |
| Border |
| --------- |
| Padding |
| --------- |
| Content |
div {
width: 200px;
padding: 10px;
border: 5px solid black;
margin: 20px;
}
Width applies only to the content.
Padding, border, and margin expand the element’s total space.
Total width = content width + left/right padding + left/right border + left/right margin
Total height = content height + top/bottom padding + top/bottom border + top/bottom margin
To include padding and border in the width/height of the element:
* {
box-sizing: border-box;
}
✅ This prevents layout issues and keeps the box size predictable.
Q1. Create a <div>
with 300px width and 20px padding.
Q2. Add a 5px solid red border around all paragraphs.
Q3. Set a 15px margin around a container div.
Q4. Write CSS to apply 10px padding and 5px margin to all headings.
Q5. Use the box-sizing
property to include padding and border in the element’s width.
Q6. Write a rule that sets a 2px dotted green border for an image.
Q7. Apply 25px top and bottom margin and 10px left and right padding to a section.
Q8. Set different border styles for each side of a box (top, right, bottom, left).
Q9. Create a CSS class .box
that has 10px padding, 3px border, and 15px margin.
Q10. Apply border-box sizing to all elements using the universal selector.
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)