HomebaseWorks

HTML and CSS interview questions

Questions interviewers commonly use to see whether you understand how the browser lays out and styles a page.

EWritten by the HomebaseWorks editorial team · reviewed 26 Oct 2026
1
What is the difference between content-box and border-box?

With content-box, width sets only the content, and padding and border are added on top. With border-box, width includes padding and border, so a 300px card stays 300px when you add padding. I usually set border-box globally because it makes layouts easier to reason about.

2
How does CSS decide which rule applies when two rules conflict?

First importance, then specificity, then source order. I count specificity as ids, then classes and attributes, then elements, and compare from the left. If a rule is not applying, I check in developer tools which rule is crossing it out instead of reaching for !important.

3
When would you use grid instead of flexbox?

Flexbox suits one-dimensional rows or columns, such as a navigation bar where items size to their content. Grid suits two-dimensional layouts where columns must line up across rows, like a product gallery. I often combine them: grid for the page, flexbox inside each card.

Advertisement
4
How do you make a form accessible?

Every field gets a visible label linked with for and id, related options go in a fieldset with a legend, and errors are shown as text next to the field, not only as a red border. I also test that the whole form can be completed with the keyboard alone.

5
What does mobile-first CSS mean in practice?

I write the base styles for a narrow screen, usually a single column, and then add min-width media queries that introduce wider layouts. This keeps the small-screen CSS simple and means phones do not download and then undo desktop rules.

6
Why use semantic elements if a div can be styled the same way?

Semantic elements carry meaning that screen readers, search engines and browser features use. A nav or main element gives screen reader users landmarks to jump to, and a real button is focusable and works with Enter and Space without extra code. A styled div gives none of that for free.

Practise out loud. Say each answer once as written, then again in your own words with your own number or story.

Have a number ready. "My HTML and CSS score is at benchmark on a timed test" is a stronger answer than "I am good at it". Take the test and quote the result.

Advertisement
Continue with HTML and CSS4 lessons · 1 interview set · 1 test · 1 certificate
Not tested

More in Web and app