MyInternships.in

CSS Examples & Practice

CSS Quiz

Ready to check what you know? This 15-question multiple-choice quiz covers selectors, the box model, colors, flexbox, grid, positioning and specificity. Read each question, pick your answer, then check the answer table below with a one-line explanation for every question.


Questions

  1. What does CSS stand for? (a) Computer Style Sheets (b) Cascading Style Sheets (c) Creative Style System (d) Colorful Style Sheets
  2. Which property changes the text color? (a) font-color (b) text-style (c) color (d) foreground
  3. Which selector targets an element by its id? (a) .id (b) #id (c) *id (d) @id
  4. In the box model, which property adds space INSIDE the border? (a) margin (b) padding (c) gap (d) border-spacing
  5. Which value of display removes an element from the layout entirely? (a) hidden (b) none (c) invisible (d) collapse
  6. Which property makes a flex container? (a) display: flex (b) flex: on (c) layout: flex (d) box: flex
  7. In flexbox, which property aligns items along the main axis? (a) align-items (b) justify-content (c) align-content (d) place-self
  8. How do you write a comment in CSS? (a) // comment (b) <!-- comment --> (c) /* comment */ (d) # comment
  9. Which unit is relative to the root element font size? (a) px (b) em (c) rem (d) pt
  10. Which position value positions relative to the nearest positioned ancestor? (a) static (b) relative (c) absolute (d) fixed
  11. What is the specificity winner among these? (a) an id selector (b) a class selector (c) an element selector (d) the universal selector
  12. Which property creates rounded corners? (a) corner-radius (b) border-radius (c) round (d) radius
  13. In CSS Grid, which property defines the columns? (a) grid-columns (b) grid-template-columns (c) columns (d) grid-cols
  14. Which pseudo-class styles a link the user is hovering? (a) :active (b) :focus (c) :hover (d) :visited
  15. Which rule makes styles apply only on screens up to 600px wide? (a) @media (max-width: 600px) (b) @screen 600 (c) @if width<600 (d) @responsive 600

Answers and explanations

#AnswerWhy
1(b) Cascading Style SheetsCSS describes how HTML elements are displayed; styles cascade by source order and specificity.
2(c) colorThe color property sets the text (foreground) color; background-color sets the background.
3(b) #idA hash targets an id; a dot targets a class.
4(b) paddingPadding is space inside the border; margin is space outside it.
5(b) nonedisplay:none removes the element and its box from the layout entirely.
6(a) display: flexThis turns an element into a flex container so its children become flex items.
7(b) justify-contentjustify-content aligns items along the main axis; align-items works on the cross axis.
8(c) /* comment */CSS uses slash-star comment syntax; HTML uses angle-bracket comments.
9(c) remrem is relative to the root (html) font size; em is relative to the element's own font size.
10(c) absoluteposition:absolute positions relative to the nearest ancestor that is not static.
11(a) an id selectorIds have the highest specificity of these four, so they win.
12(b) border-radiusborder-radius rounds the corners of an element's box.
13(b) grid-template-columnsIt defines the number and size of columns in a grid container.
14(c) :hoverThe :hover pseudo-class applies while the pointer is over the element.
15(a) @media (max-width: 600px)A max-width media query applies styles at that width and below.
💡

Scoring: 13-15 excellent, 9-12 solid, below 9 review the tutorial sections on selectors, the box model and flexbox, then try again.

Related CSS Topics

Keep learning with these closely related tutorials.

Ready to use your CSS skills?

Find web development internships and fresher jobs across India.

Browse Web Dev Internships