Top HTML5 & CSS3 Questions for 2025 Interviews
By JobQNA Team • Updated: Jan 18, 2025
Frontend interviews aren't just about JavaScript. You can't build a website without a solid understanding of HTML structure and CSS layout. Here are the most critical concepts you need to know.
1. What are Semantic Tags in HTML5?
Semantic tags clearly describe their meaning to both the browser and the developer. They are crucial for SEO and Accessibility (Screen Readers).
<div id="header"></div>
<!-- Semantic -->
<header></header>
<nav></nav>
<article></article>
<footer></footer>
2. Explain the CSS Box Model
Every element on a web page is essentially a rectangular box. The box model consists of four parts:
- Content: The actual text or image.
- Padding: Space between content and border (inside).
- Border: Line surrounding padding and content.
- Margin: Space outside the border (spacing between elements).
box-sizing: border-box;. It ensures that padding and border are included in the element's total width/height, making layout calculations much easier.
3. Flexbox vs. CSS Grid: When to use which?
This is the most confusing topic for beginners.
Flexbox (1D Layout)
Use Flexbox when you want to arrange items in a single row OR a single column. It's perfect for navigation bars, centering items, or aligning buttons.
display: flex;
justify-content: center;
align-items: center;
}
CSS Grid (2D Layout)
Use Grid when you need to control both rows AND columns at the same time. It's best for full page layouts, photo galleries, or dashboard structures.
4. The Classic Question: How to Center a Div?
Before Flexbox, this was hard. Now, it's just 3 lines of code.
display: flex;
justify-content: center; /* Horizontal */
align-items: center; /* Vertical */
height: 100vh;
}
5. What is CSS Specificity?
If two rules conflict, the one with higher specificity wins. The hierarchy is:
- Inline Styles (
style="...") - Highest - IDs (
#header) - Classes (
.btn), Attributes, Pseudo-classes - Elements (
div,h1) - Lowest
Conclusion
Mastering layouts with Flexbox/Grid and understanding the Box Model are the two most important skills for a UI developer. Practice building a simple landing page to test your knowledge.