Challenge - 5 Problems
CSS Comment Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
📝 Syntax
intermediate2: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; */
}Attempts:
2 left
💡 Hint
Look at which color property is active and which is commented out.
✗ Incorrect
CSS comments start with /* and end with */. The blue color line is commented out, so it is ignored. The red color line is active, so the paragraph text will be red.
🧠 Conceptual
intermediate2:00remaining
Which CSS comment style is valid?
Which of the following is the correct way to write a comment in CSS?
Attempts:
2 left
💡 Hint
CSS comments use a special pair of characters to start and end.
✗ Incorrect
CSS comments must start with /* and end with */. Other styles like //, , or # are not valid in CSS and will cause errors or be ignored.
❓ selector
advanced2: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; */
}Attempts:
2 left
💡 Hint
Only uncommented properties apply.
✗ Incorrect
Both orange and purple color lines are inside comments, so they are ignored. Only the green color line applies, so the div text will be green.
❓ layout
advanced2: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;
}Attempts:
2 left
💡 Hint
Think about how browsers handle unclosed comments.
✗ Incorrect
If a CSS comment is not closed, the browser treats everything after the /* as part of the comment. The background-color property precedes the /* and applies, but the color property and any following CSS are ignored.
❓ accessibility
expert2:00remaining
Why should comments in CSS be used carefully for accessibility?
Which statement about CSS comments and accessibility is true?
Attempts:
2 left
💡 Hint
Consider how browsers and assistive technologies treat CSS comments.
✗ Incorrect
CSS comments are ignored by browsers and do not appear in the rendered page or affect screen readers. They do not improve or harm accessibility directly.