StudyFox
कीमतेंब्लॉगएक्सटेंशनमुफ़्त टूल
  • कीमतें
  • ब्लॉग
  • एक्सटेंशन
  • मुफ़्त टूल
  • शुरू करेंसाइन इन
StudyFox

अपने नोट्स, PDF और स्लाइड्स को फ़्लैशकार्ड, क्विज़, नोट्स और माइंड मैप में बदलें।

StudyFox खोलें

स्टडी टूल्स

  • होमवर्क हेल्पर
  • नोट मेकर
  • फ़्लैशकार्ड मेकर
  • क्विज़ मेकर
  • माइंड मैप मेकर

प्रोडक्ट

  • कीमतें
  • Chrome एक्सटेंशन
  • मुफ़्त एक्सटेंशन
  • स्टडी सेट देखें
  • ब्लॉग

सहायता

  • सहायता केंद्र
  • संपर्क करें
  • गोपनीयता नीति
  • सेवा की शर्तें

तुलना करें

  • Chegg का विकल्प
  • Course Hero का विकल्प
  • Coursology का विकल्प
  • Photomath का विकल्प
  • Gauthmath का विकल्प
  • PhotoSolve का विकल्प
  • CollegeTools का विकल्प
  • Transcript का विकल्प
  • SmartSolve का विकल्प
  • Homeworkify का विकल्प
  • AnswersAi का विकल्प
  • StudyX का विकल्प
  • Quizlet का विकल्प
  • Anki का विकल्प
  • Knowt का विकल्प
  • Brainscape का विकल्प
  • सभी तुलनाएँ

© 2026 StudyFox AI. सर्वाधिकार सुरक्षित।

  • X
  • Discord
  • Instagram
ExploreEngineering & TechWeb DevelopmentHTML & CSS Practice Quiz: Selectors, Box Model, Flexbox & Grid

Quiz · Medium

HTML & CSS Practice Quiz: Selectors, Box Model, Flexbox & Grid

Twenty-four exam-style questions on semantic HTML, selectors, the box model, flexbox, grid, units and responsive design, with diagram questions.

by Kill h.24 questionsCreated Nov 20, 2026, 08:26 PM
Web Development· HTML & CSSTags#html#css#flexbox#grid

24 questions

  1. 1

    Which element is the best choice for the main block of site navigation links?

    • A

      <aside>

    • B

      <div class="nav">

    • <nav>

    • D

      <menu>

    <nav> is the semantic landmark for major navigation blocks, and screen readers can jump to it. A <div class="nav"> has no meaning, <aside> is for tangential content, and <menu> is meant for a list of commands, not site navigation.

  2. 2

    In this diagram, which layer sits directly between the content and the border?

    • A

      Gutter

    • Padding

    • C

      Margin

    • D

      Outline

    Padding is the space between content and border, and the element's background shows through it. Margin is outside the border. Outline is drawn outside the border and is not part of the box model. A gutter is a grid or column gap, not a box layer.

  3. 3

    An element has width: 300px; padding: 10px; border: 5px solid; and default box-sizing: content-box. How wide is the box on screen (excluding margin)?

    • A

      320px

    • B

      300px

    • 330px

    • D

      315px

    With content-box, width is the content only: 300 + 10 + 10 + 5 + 5 = 330px. 300px would be the case under border-box; 315px and 320px each forget one of the two sides of padding or border.

  4. 4

    The same element uses box-sizing: border-box. What is the width of its content area?

    • A

      330px

    • B

      300px

    • C

      285px

    • 270px

    Under border-box, the 300px includes padding and border: content = 300 - (10 + 10) - (5 + 5) = 270px. 285px forgets one side's padding and border; 330px is the content-box total width.

  5. 5

    Which image shows justify-content: space-between for a row flex container?

    • A
    • B
    • D

    space-between puts the first item at the start and the last at the end with equal gaps between. space-around leaves half-size gaps at the edges, center groups items in the middle and flex-end packs them at the end.

    Image: Hunsvotti, CC BY-SA 4.0, via Wikimedia Commons.

  6. 6

    Which media query belongs to a mobile-first stylesheet?

    • A

      @media screen and (width = phone) { ... }

    • @media (min-width: 768px) { ... }

    • C

      @media (max-width: 768px) { ... }

    • D

      @media (device: mobile) { ... }

    Mobile-first means base styles target small screens and min-width queries add layout as the screen gets wider. max-width queries are the desktop-first approach. The other two are not valid media features.

  7. 7

    html { font-size: 16px; }, a <div> with font-size: 1.5rem, and a <p> inside it with font-size: 1.5em. What is the <p> font size?

    • A

      27px

    • 36px

    • C

      22.5px

    • D

      24px

    The div is 1.5 x 16 = 24px. em is relative to the parent's font size, so the p is 1.5 x 24 = 36px. 24px would be correct if the p used rem.

  8. 8

    Which image shows justify-content: space-around?

    • B
    • C
    • D

    With space-around, each item has equal space on both sides, so the gap at the container edges is half the gap between items. In the space-between image the first and last items touch the edges.

    Image: Hunsvotti, CC BY-SA 4.0, via Wikimedia Commons.

  9. 9

    Which selector matches only the direct <li> children of a <ul>?

    • ul > li

    • B

      ul ~ li

    • C

      ul + li

    • D

      ul li

    > is the child combinator. ul li also matches nested list items at any depth, ul + li would need an li that follows a ul as a sibling, and ul ~ li any later sibling li.

  10. 10

    Which declaration vertically centers the children of a row-direction flex container?

    • A

      vertical-align: middle

    • B

      justify-content: center

    • C

      text-align: center

    • align-items: center

    In a row, the cross axis is vertical, controlled by align-items. justify-content works along the main (horizontal) axis. text-align only aligns inline content, and vertical-align does not apply to flex items.

  11. 11

    .title { color: blue; } comes first in the stylesheet and p { color: red; } comes after. A <p class="title"> is shown in which color?

    • A

      Red

    • Blue

    • C

      The browser default

    • D

      Purple (they mix)

    A class selector (0,1,0) has higher specificity than a type selector (0,0,1), so the earlier .title rule wins. Source order only matters when specificity is equal. CSS never mixes conflicting values.

  12. 12

    An absolutely positioned element is placed relative to what?

    • A

      The viewport

    • The nearest ancestor that has a position other than static (or the initial containing block if none)

    • C

      The previous sibling

    • D

      Its parent element, always

    position: absolute looks up the tree for the nearest positioned ancestor. A common bug is forgetting position: relative on the intended parent, so the element ends up positioned against the page. fixed is the one that uses the viewport.

  13. 13

    In grid-template-columns: 1fr 2fr 1fr, how much of the free width does the middle column get?

    • A

      One quarter

    • B

      Two thirds

    • C

      One third

    • Half (50%)

    The fr values add up to 4, and the middle gets 2 of them, so 2/4 = 50% of the free space (after gaps and fixed tracks). One third would be 1fr 1fr 1fr.

  14. 14

    How many column lines does this 3-column grid have?

    • A

      2

    • B

      3

    • 4

    • D

      6

    N column tracks are bounded by N + 1 lines, so 3 columns have 4 column lines numbered 1 to 4 (and -4 to -1 from the end). The 6 in the picture refers to row lines of the 5 rows.

    Image: Hunsvotti, CC BY-SA 4.0, via Wikimedia Commons.

  15. 15

    What does grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)) give you?

    • A

      Exactly 200px wide columns

    • B

      Always three columns

    • As many columns as fit, each at least 200px wide, sharing leftover space

    • D

      A single column on every screen

    auto-fit creates as many tracks as fit the width, minmax(200px, 1fr) lets each track grow to share leftover space. It makes a responsive card grid without media queries.

  16. 16

    Which <script> attribute downloads in parallel and runs after parsing finishes, keeping document order?

    • A

      async

    • B

      lazy

    • defer

    • D

      preload

    defer waits until HTML parsing finishes and runs deferred scripts in order. async runs as soon as the file arrives, in any order. lazy is not a script attribute, and preload is a <link rel> hint.

  17. 17

    True or False: a placeholder attribute is an acceptable replacement for a <label>.

    • False

    • B

      True

    Placeholders vanish while typing, often have poor contrast, and are not a reliable accessible name. Use a visible <label> (and a placeholder only for an example value).

  18. 18

    What should the alt attribute be for a purely decorative image?

    • A

      The file name

    • B

      Leave the attribute out entirely

    • An empty string: alt=""

    • D

      The word "image"

    Empty alt tells screen readers to skip the image. A file name or "image" is noise, and leaving out alt lets some readers read the file URL.

  19. 19

    The lower diagram shows the old Internet Explorer box model. Which box-sizing value makes modern browsers behave like it?

    • border-box

    • B

      margin-box

    • C

      content-box

    • D

      padding-box

    In the IE model, width covers content + padding + border, which is exactly box-sizing: border-box. content-box is the W3C default shown in the top diagram. padding-box and margin-box are not valid box-sizing values.

    Image: Warren and Will Pittenger, public domain, via Wikimedia Commons.

  20. 20

    A block has margin-bottom: 20px and the next block has margin-top: 30px. What is the space between them?

    • A

      10px

    • 30px

    • C

      50px

    • D

      20px

    Adjacent vertical margins collapse to the larger of the two (not the sum). It would be 50px in a flex or grid container, where margins do not collapse.

  21. 21

    How do you make three radio buttons mutually exclusive?

    • A

      Give them the same id

    • Give them the same name attribute

    • C

      Wrap them in a <div>

    • D

      Give each one required

    Radios with the same name form a group, and only one can be checked. id values must be unique, a div has no effect on grouping, and required only demands a selection.

  22. 22

    In a table of items, tr:nth-child(odd) styles which rows?

    • A

      Only the first row

    • The 1st, 3rd, 5th... rows

    • C

      Rows with an odd number of cells

    • D

      The 2nd, 4th, 6th... rows

    odd is the same as 2n+1, counting from 1. even would match rows 2, 4, 6.

  23. 23

    You set z-index: 5 on an element but it has no effect. What is the most likely reason?

    • It is position: static (z-index only applies to positioned elements and flex/grid items)

    • B

      z-index needs a value above 100

    • C

      z-index works only inside media queries

    • D

      z-index only works on images

    A static element ignores z-index. Add position: relative (or make it a flex or grid item). The value itself does not need to be large, and it works for any element type.

  24. 24

    What does the <meta name="viewport" content="width=device-width, initial-scale=1"> tag do?

    • A

      Loads the mobile version of the site from the server

    • Makes the page layout width match the device width so responsive CSS works on phones

    • C

      Makes the page zoom in automatically

    • D

      Disables printing

    Without it, mobile browsers lay the page out at a wide virtual width (about 980px) and scale down, so media queries and fluid layouts behave like on a desktop. It does not zoom, block printing or fetch another URL.