0
0
CSSmarkup~20 mins

Comments in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
CSS Comment Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate
2:00remaining
What is the output of this CSS snippet?
Consider the following CSS code. What color will the paragraph text be rendered in the browser?
CSS
p {
  color: red; /* This is a comment */
  /* color: blue; */
}
AThe paragraph text will be blue.
BThe paragraph text will be red.
CThe paragraph text will be black (default).
DThe CSS will cause a syntax error and no color will apply.
Attempts:
2 left
💡 Hint
Look at which color property is active and which is commented out.
🧠 Conceptual
intermediate
2:00remaining
Which CSS comment style is valid?
Which of the following is the correct way to write a comment in CSS?
A/* This is a comment */
B<!-- This is a comment -->
C// This is a comment
D# This is a comment
Attempts:
2 left
💡 Hint
CSS comments use a special pair of characters to start and end.
selector
advanced
2:00remaining
How do comments affect CSS selectors?
Given this CSS code, what color will the div text be?
CSS
div {
  color: green; /* color: orange; */
  /* color: purple; */
}
AThe div text will be green.
BThe div text will be orange.
CThe div text will be purple.
DThe div text will be black (default).
Attempts:
2 left
💡 Hint
Only uncommented properties apply.
layout
advanced
2:00remaining
What happens if a comment is not closed in CSS?
What will happen if you write this CSS code?
CSS
body {
  background-color: white; /* This comment is not closed
  color: black;
}
AThe browser applies only background-color but not color.
BThe browser applies both background-color and color correctly.
CThe browser ignores the entire CSS after the unclosed comment, so color and background-color won't apply.
DThe browser throws a syntax error and stops rendering the page.
Attempts:
2 left
💡 Hint
Think about how browsers handle unclosed comments.
accessibility
expert
2:00remaining
Why should comments in CSS be used carefully for accessibility?
Which statement about CSS comments and accessibility is true?
ACSS comments can be read aloud by screen readers if they contain important info.
BComments in CSS can improve accessibility by explaining styles for screen readers.
CLarge CSS comments can slow down screen readers and harm accessibility.
DComments in CSS are ignored by browsers and do not affect accessibility directly.
Attempts:
2 left
💡 Hint
Consider how browsers and assistive technologies treat CSS comments.