HTML & CSS MCQ
Test your HTML & CSS knowledge with 100 multiple choice questions covering fundamentals to advanced concepts, with instant feedback and explanations.
What does HTML stand for?
2Which HTML tag is used to define the largest heading?
3Which tag is used to create a hyperlink?
4Which attribute specifies the URL of the page a link goes to?
5Which tag is used to insert an image?
6What is the correct HTML element for inserting a line break?
7Which CSS property changes the text color of an element?
8How do you link an external CSS file to an HTML document?
9Which CSS selector targets an element with id="header"?
10Which CSS selector targets all elements with class="box"?
11What does the CSS "box model" describe?
12Which HTML tag is used to create an unordered (bulleted) list?
13What is the purpose of the <head> element in an HTML document?
14Which CSS property is used to change the font size of text?
15What does the "alt" attribute on an <img> tag provide?
16Which HTML element is used to define the title shown in the browser tab?
17What is the correct syntax for a CSS comment?
18Which CSS property controls the space between an element's border and its content?
19What is the correct HTML for creating a checkbox?
20Which CSS property is used to make text bold?
21What does the CSS value "display: none" do to an element?
22Which tag is used to define a table row?
23What is the purpose of the <form> element?
24Which CSS unit is relative to the font-size of the root element (<html>)?
25What does the "class" attribute allow you to do?
26Which property is used to set the background color of an element?
27What is the correct way to add an inline style to an HTML element?
28Which HTML5 element is used to define independent, self-contained content, like a blog post?
29What does the CSS "text-align: center" property do?
30Which doctype declaration is used for HTML5?
31What does the CSS property "border-radius" do?
32How do you make text italic using CSS?
33Which attribute is used to specify that an input field must be filled out before submitting a form?
34What does the CSS "cursor: pointer" property do?
35Which HTML element represents the main navigation links of a page?
36What is the purpose of the "viewport" meta tag, e.g. "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">"?
37Which CSS property sets the width of an element's border?
38What does the HTML "<strong>" tag do?
39What is the difference between <div> and <span>?
40Which CSS property controls the stacking order of overlapping positioned elements?
What is the difference between "margin: 0 auto" centering a block element and "text-align: center"?
2What does "box-sizing: border-box" change about how width and height are calculated?
3What is the difference between "position: relative" and "position: absolute"?
4What does CSS specificity determine, and which of these has the highest specificity: an inline style, an ID selector, or a class selector?
5What is the purpose of CSS Flexbox's "justify-content" property?
6What does the "align-items" property control in a flex container?
7What is the difference between CSS Grid and Flexbox at a high level?
8What does a CSS media query like "@media (max-width: 600px) { ... }" do?
9What is the purpose of the ":hover" pseudo-class?
10What is the difference between "em" and "rem" units in CSS?
11What does the CSS "transition" property do?
12What is semantic HTML, and why is it preferred?
13What does the CSS pseudo-element "::before" do?
14What is the effect of "overflow: hidden" on a container with content larger than its size?
15What does the "fr" unit represent in CSS Grid, e.g. "grid-template-columns: 1fr 2fr"?
16What is the purpose of the "alt", "title", and ARIA attributes for accessibility?
17What does the CSS "calc()" function allow?
18What is the difference between "visibility: hidden" and "display: none"?
19What does the ":nth-child(2n)" pseudo-class select?
20What is the purpose of the "data-*" custom attributes in HTML, e.g. "data-user-id=\"42\""?
21What does "min-width" and "max-width" allow you to do for responsive design?
22What does the HTML5 <video> element's "controls" attribute do?
23What is "CSS specificity" calculated from when comparing two selectors like "#nav .link" and ".container a"?
24What does the "flex-wrap: wrap" property do in a flex container?
25What is the purpose of the <label> element in forms, and how does "for" attribute relate to it?
26What does "white-space: nowrap" do to text content?
27What is the difference between "<script>", "<script defer>", and "<script async>"?
28What does the CSS "object-fit: cover" property do for an <img> or <video> element?
29What is the purpose of CSS custom properties (variables), e.g. "--main-color: #336699;" used as "color: var(--main-color);"?
30What does the "grid-template-areas" property allow you to do?
31What does the "<picture>" element with multiple "<source>" tags enable?
32What does the CSS "::placeholder" pseudo-element style?
33What is the purpose of the "outline" CSS property, and why should it not simply be set to "none" for focused interactive elements?
34What does "float: left" traditionally do, and why is it now mostly replaced by Flexbox/Grid for layout?
35What is the difference between "<section>" and "<div>" elements semantically?
36What does the CSS "gap" property do when used in a flex or grid container?
37What does the HTML "<button type=\"submit\">" versus "<button type=\"button\">" difference matter for?
38What does the CSS "background-size: cover" value do for a background image?
39What is the purpose of the "rel=\"noopener noreferrer\"" attribute on a link opened with "target=\"_blank\""?
40What does the CSS "filter" property allow, e.g. "filter: blur(5px)" or "filter: grayscale(100%)"?
What is the CSS "stacking context" and how is a new one created?
2What is the difference between "reflow" and "repaint" in browser rendering, and why does this matter for performance?
3What does "will-change: transform" hint to the browser, and what is a risk of overusing it?
4What is the Cascade Layers feature (@layer) in modern CSS designed to solve?
5What is "Critical CSS" and why might it be extracted and inlined in the <head>?
6How does the CSS "contain" property (e.g. "contain: layout paint") help with rendering performance?
7What is the purpose of "ARIA live regions" (e.g. "aria-live=\"polite\"")?
8What is the difference between "rendering" via the "content-visibility: auto" CSS property compared to lazy-loading images via "loading=\"lazy\""?
9What does the CSS ":is()" and ":where()" pseudo-classes allow, and what is the key difference between them?
10What is a "Flash of Unstyled Content" (FOUC) and what commonly causes it?
11What is the purpose of CSS "logical properties" like "margin-inline-start" versus physical properties like "margin-left"?
12What does the "isolation: isolate" CSS property do, and when is it useful?
13How does the CSS "@supports" rule enable progressive enhancement?
14What is the significance of the "loading" attribute value "lazy" on an <iframe>, and what is a potential downside if applied to above-the-fold content?
15What does the CSS "@font-face" rule's "font-display" property control, e.g. "font-display: swap"?
16What is the difference between "inline", "inline-block", and "block" display values regarding layout behavior?
17What problem does "container queries" (e.g. "@container (min-width: 400px) { ... }") solve compared to traditional media queries?
18How does the browser's rendering pipeline order (Parse HTML → Build DOM/CSSOM → Render Tree → Layout → Paint → Composite) explain why CSS placed at the top of <head> is generally recommended?
19What is the purpose of the "prefers-reduced-motion" media feature?
20What does the CSS "aspect-ratio" property allow you to do, and how did developers commonly achieve this effect before it was introduced?