HTML5 & CSS3 Top 50 Viva Questions & Frontend Practical Lab Guide (2026 Edition)
Score full marks in your BCA, B.Tech, or NIELIT Web Design lab viva: semantic elements, CSS Box Model, Flexbox vs Grid, z-index, animations, and CSS positioning.
Web Design and Internet Technology practical exams are mandatory for university degrees (BCA, B.Sc IT, B.Tech CSE) and government diplomas (NIELIT O Level M2-R5). During external lab vivas, examiners evaluate whether you understand browser rendering mechanics, layout algorithms, accessibility, and modern CSS3 architectures beyond basic tag memorization.
Here is an essential guide to the top 50 HTML5 and CSS3 viva questions, compiled by Er. Sumit Kumar at MSK Institute.
1. What is the DOCTYPE declaration and why is <!DOCTYPE html> essential?
The <!DOCTYPE html> declaration is not an HTML tag; it is an instruction to the web browser about the version of the HTML standard the document is written in.
- In HTML5,
<!DOCTYPE html>is case-insensitive, clean, and concise. - Why it matters: Without it, modern browsers drop into "Quirks Mode", emulating outdated 1990s Netscape/Internet Explorer rendering bugs, which shatters modern CSS layouts.
2. What are Semantic Elements in HTML5 and why are they preferred over <div>?
Semantic tags clearly describe their meaning and purpose to both the browser and developer:
- Non-semantic tags:
<div>,<span>(tell nothing about their content). - Semantic tags:
<header>,<nav>,<main>,<article>,<section>,<aside>,<footer>.
3 Major Advantages:
- 1SEO (Search Engine Optimization): Google web crawlers prioritize content inside
<article>and<main>over generic wrapper divs. - 2Accessibility (a11y): Screen readers used by visually impaired users use semantic landmarks to jump directly to primary page content.
- 3Clean Code Maintenance: Developers instantly understand the structural hierarchy of the codebase.
3. Explain the CSS Box Model (With Diagram)
Every visible element in HTML is treated as a rectangular box by the browser rendering engine. From inside to outside:
+-------------------------------------------------+ | Margin | | +-----------------------------------------+ | | | Border | | | | +---------------------------------+ | | | | | Padding | | | | | | +-------------------------+ | | | | | | | Content (Width) | | | | | | | +-------------------------+ | | | | | +---------------------------------+ | | | +-----------------------------------------+ | +-------------------------------------------------+
- Content: The text, image, or video itself.
- Padding: Clear space around the content, inside the border (inherits element background color).
- Border: A stroke enclosing the padding and content.
- Margin: Transparent space outside the border separating the element from neighboring elements.
box-sizing: border-box; do?"
Answer: By default (content-box), adding padding expands the element's actual rendered width. With box-sizing: border-box;, padding and border are included inside the specified width and height, preventing layout breakage!4. What is the Difference Between CSS Flexbox and CSS Grid?
| Feature | CSS Flexbox (Flexible Box) | CSS Grid |
|---|---|---|
| Dimension | 1-Dimensional (Row OR Column at a time) | 2-Dimensional (Rows AND Columns simultaneously) |
| Philosophy | Content-first (Items dictate placement) | Layout-first (Predefined grid tracks dictate placement) |
| Best Used For | Navigation bars, button groups, vertical centering | Full-page layouts, photo galleries, dashboard widget grids |
| Alignment | justify-content, align-items | grid-template-columns, grid-template-rows, gap |
5. What are the CSS position Properties?
- 1
static: Default for all elements. Follows natural document flow. (top/left/right/bottomdo nothing). - 2
relative: Positioned relative to its normal position without affecting sibling elements. - 3
absolute: Positioned relative to its closest positioned ancestor (an ancestor with any position other thanstatic). Removed from normal flow. - 4
fixed: Positioned relative to the viewport browser window. Stays fixed on screen during scrolling (used for sticky headers or floating WhatsApp chat buttons). - 5
sticky: Hybrid of relative and fixed. Acts relative until a scroll threshold is met, then "sticks" to the screen.
6. What is the Difference Between display: none and visibility: hidden?
display: none;: Completely removes the element from the document rendering flow. It takes up zero space on the screen.visibility: hidden;: Hides the element visually, but its layout space is preserved as a blank placeholder.
7. How Does CSS Specificity Work? (Calculation Formula)
When two conflicting CSS rules target the same element, the browser uses Specificity Hierarchy:
$$\text{Inline Styles (1000)} > \text{IDs (100)} > \text{Classes / Attributes / Pseudo-classes (10)} > \text{Elements / Pseudo-elements (1)}$$
!important rule overrides all normal specificity, but overusing it makes code unmaintainable.8. Summary & Top 3 Tips for Scoring Grade A in Lab Vivas
- 1Demonstrate Responsive Design: Always know how to write
@media (max-width: 768px)media queries to handle mobile viewports. - 2Test Code Live: Run and edit live HTML5/CSS3 snippets in our interactive MSK Code Playground.
- 3Join Full-Stack Mentorship: Learn semantic web design, responsive Tailwind CSS, and React in our comprehensive Full-Stack Web Development Bootcamp at MSK Institute!
Master These Skills in Our Offline Labs
HTML5 Complete Course
The definitive, comprehensive HTML5 full course. Master modern semantic architecture, accessible web forms, responsive multimedia, ARIA, SEO meta tags, and browser APIs with live hands-on projects.
Full-Stack Web Development Bootcamp
Complete 3-in-1 combo bootcamp covering Frontend UI, React Engineering, and Node.js Backend API Development. Build full-stack production web applications from scratch.