-
Hajipur, Bihar, 844101
A CSS website layout defines the visual structure and organization of a webpage. It determines how headers, navigation bars, sidebars, content areas, and footers are positioned and styled.
You can build layouts using techniques such as:
CSS Flexbox
CSS Grid
float
and clear
Positioning (relative
, absolute
, etc.)
Multi-column layouts
Header – Top bar with logo or site name
Navigation (Nav) – Menu links
Main Content – Central section for page content
Sidebar – Optional for ads, links, or tools
Footer – Bottom section with copyright/info
.container {
display: flex;
}
.sidebar {
width: 25%;
}
.content {
width: 75%;
}
Use Flexbox for 1D layouts (row or column).
.container {
display: grid;
grid-template-columns: 25% 75%;
}
Use Grid for 2D layouts — rows and columns.
.sidebar {
float: left;
width: 25%;
}
.content {
float: left;
width: 75%;
}
Floats are older technique, still useful sometimes.
.header {
position: fixed;
top: 0;
width: 100%;
}
Used for sticky headers, footers, etc.
.columns {
column-count: 3;
column-gap: 20px;
}
Useful for text-heavy pages like blogs.
Q1. Create a basic two-column layout using Flexbox.
Q2. Build a 3-column layout with Grid (left, center, right).
Q3. Create a header and footer with fixed width.
Q4. Make a responsive sidebar that collapses on small screens.
Q5. Float an image to the right of the content block.
Q6. Create a sticky header that stays at the top on scroll.
Q7. Design a footer that sticks to the bottom of the page.
Q8. Create equal-height columns using Flexbox.
Q9. Build a centered layout with max width of 1200px.
Q10. Use column-count
to split text into 2 columns.
Q1: Which CSS layout method is best for 2D layouts?
Q2: What does display: flex; do?
Q3: Which property is used to make a sticky header?
Q4: What does grid-template-columns: 1fr 2fr; do?
Q5: Which layout method allows wrapping content to the next line?
Q6: Which layout method is oldest and now less preferred?
Q7: How do you define three columns with equal width in Grid?
Q8: What is the default direction of Flexbox?
Q9: What does column-count: 3; do?
Q10: What unit is best for responsive widths?