🎨

HTML & CSS MCQ

Test your HTML & CSS knowledge with 100 multiple choice questions covering fundamentals to advanced concepts, with instant feedback and explanations.

100 Questions 40 Beginner 40 Intermediate 20 Advanced
1

What does HTML stand for?

2

Which HTML tag is used to define the largest heading?

3

Which tag is used to create a hyperlink?

4

Which attribute specifies the URL of the page a link goes to?

5

Which tag is used to insert an image?

6

What is the correct HTML element for inserting a line break?

7

Which CSS property changes the text color of an element?

8

How do you link an external CSS file to an HTML document?

9

Which CSS selector targets an element with id="header"?

10

Which CSS selector targets all elements with class="box"?

11

What does the CSS "box model" describe?

12

Which HTML tag is used to create an unordered (bulleted) list?

13

What is the purpose of the <head> element in an HTML document?

14

Which CSS property is used to change the font size of text?

15

What does the "alt" attribute on an <img> tag provide?

16

Which HTML element is used to define the title shown in the browser tab?

17

What is the correct syntax for a CSS comment?

18

Which CSS property controls the space between an element's border and its content?

19

What is the correct HTML for creating a checkbox?

20

Which CSS property is used to make text bold?

21

What does the CSS value "display: none" do to an element?

22

Which tag is used to define a table row?

23

What is the purpose of the <form> element?

24

Which CSS unit is relative to the font-size of the root element (<html>)?

25

What does the "class" attribute allow you to do?

26

Which property is used to set the background color of an element?

27

What is the correct way to add an inline style to an HTML element?

28

Which HTML5 element is used to define independent, self-contained content, like a blog post?

29

What does the CSS "text-align: center" property do?

30

Which doctype declaration is used for HTML5?

31

What does the CSS property "border-radius" do?

32

How do you make text italic using CSS?

33

Which attribute is used to specify that an input field must be filled out before submitting a form?

34

What does the CSS "cursor: pointer" property do?

35

Which HTML element represents the main navigation links of a page?

36

What is the purpose of the "viewport" meta tag, e.g. "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">"?

37

Which CSS property sets the width of an element's border?

38

What does the HTML "<strong>" tag do?

39

What is the difference between <div> and <span>?

40

Which CSS property controls the stacking order of overlapping positioned elements?

1

What is the difference between "margin: 0 auto" centering a block element and "text-align: center"?

2

What does "box-sizing: border-box" change about how width and height are calculated?

3

What is the difference between "position: relative" and "position: absolute"?

4

What does CSS specificity determine, and which of these has the highest specificity: an inline style, an ID selector, or a class selector?

5

What is the purpose of CSS Flexbox's "justify-content" property?

6

What does the "align-items" property control in a flex container?

7

What is the difference between CSS Grid and Flexbox at a high level?

8

What does a CSS media query like "@media (max-width: 600px) { ... }" do?

9

What is the purpose of the ":hover" pseudo-class?

10

What is the difference between "em" and "rem" units in CSS?

11

What does the CSS "transition" property do?

12

What is semantic HTML, and why is it preferred?

13

What does the CSS pseudo-element "::before" do?

14

What is the effect of "overflow: hidden" on a container with content larger than its size?

15

What does the "fr" unit represent in CSS Grid, e.g. "grid-template-columns: 1fr 2fr"?

16

What is the purpose of the "alt", "title", and ARIA attributes for accessibility?

17

What does the CSS "calc()" function allow?

18

What is the difference between "visibility: hidden" and "display: none"?

19

What does the ":nth-child(2n)" pseudo-class select?

20

What is the purpose of the "data-*" custom attributes in HTML, e.g. "data-user-id=\"42\""?

21

What does "min-width" and "max-width" allow you to do for responsive design?

22

What does the HTML5 <video> element's "controls" attribute do?

23

What is "CSS specificity" calculated from when comparing two selectors like "#nav .link" and ".container a"?

24

What does the "flex-wrap: wrap" property do in a flex container?

25

What is the purpose of the <label> element in forms, and how does "for" attribute relate to it?

26

What does "white-space: nowrap" do to text content?

27

What is the difference between "<script>", "<script defer>", and "<script async>"?

28

What does the CSS "object-fit: cover" property do for an <img> or <video> element?

29

What is the purpose of CSS custom properties (variables), e.g. "--main-color: #336699;" used as "color: var(--main-color);"?

30

What does the "grid-template-areas" property allow you to do?

31

What does the "<picture>" element with multiple "<source>" tags enable?

32

What does the CSS "::placeholder" pseudo-element style?

33

What is the purpose of the "outline" CSS property, and why should it not simply be set to "none" for focused interactive elements?

34

What does "float: left" traditionally do, and why is it now mostly replaced by Flexbox/Grid for layout?

35

What is the difference between "<section>" and "<div>" elements semantically?

36

What does the CSS "gap" property do when used in a flex or grid container?

37

What does the HTML "<button type=\"submit\">" versus "<button type=\"button\">" difference matter for?

38

What does the CSS "background-size: cover" value do for a background image?

39

What is the purpose of the "rel=\"noopener noreferrer\"" attribute on a link opened with "target=\"_blank\""?

40

What does the CSS "filter" property allow, e.g. "filter: blur(5px)" or "filter: grayscale(100%)"?

1

What is the CSS "stacking context" and how is a new one created?

2

What is the difference between "reflow" and "repaint" in browser rendering, and why does this matter for performance?

3

What does "will-change: transform" hint to the browser, and what is a risk of overusing it?

4

What is the Cascade Layers feature (@layer) in modern CSS designed to solve?

5

What is "Critical CSS" and why might it be extracted and inlined in the <head>?

6

How does the CSS "contain" property (e.g. "contain: layout paint") help with rendering performance?

7

What is the purpose of "ARIA live regions" (e.g. "aria-live=\"polite\"")?

8

What is the difference between "rendering" via the "content-visibility: auto" CSS property compared to lazy-loading images via "loading=\"lazy\""?

9

What does the CSS ":is()" and ":where()" pseudo-classes allow, and what is the key difference between them?

10

What is a "Flash of Unstyled Content" (FOUC) and what commonly causes it?

11

What is the purpose of CSS "logical properties" like "margin-inline-start" versus physical properties like "margin-left"?

12

What does the "isolation: isolate" CSS property do, and when is it useful?

13

How does the CSS "@supports" rule enable progressive enhancement?

14

What 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?

15

What does the CSS "@font-face" rule's "font-display" property control, e.g. "font-display: swap"?

16

What is the difference between "inline", "inline-block", and "block" display values regarding layout behavior?

17

What problem does "container queries" (e.g. "@container (min-width: 400px) { ... }") solve compared to traditional media queries?

18

How 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?

19

What is the purpose of the "prefers-reduced-motion" media feature?

20

What does the CSS "aspect-ratio" property allow you to do, and how did developers commonly achieve this effect before it was introduced?