0
0
CSSmarkup~20 mins

Border in CSS - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Border Mastery
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 border style?
Given the CSS below, what will be the visible border style on the element?
CSS
div {
  border: 5px dashed red;
}
AA 5px wide dotted red border around the element
BA 5px wide solid red border around the element
CNo border visible because dashed is invalid
DA 5px wide red dashed border around the element
Attempts:
2 left
💡 Hint
The border shorthand uses width, style, and color in that order.
🧠 Conceptual
intermediate
2:00remaining
How many borders will be visible with this CSS?
Consider the CSS below. How many visible borders will the element have?
CSS
div {
  border-top: 3px solid blue;
  border-right: 3px solid blue;
  border-bottom: 0;
  border-left: none;
}
AFour visible borders all blue
BNo visible borders because bottom and left hide them
CTwo visible borders: top and right
DThree visible borders: top, right, and bottom
Attempts:
2 left
💡 Hint
border-bottom: 0 and border-left: none both remove those borders.
selector
advanced
2:00remaining
Which CSS selector applies border only to paragraphs inside a section?
You want to add a 2px solid green border only to

elements inside

elements. Which CSS selector is correct?
Asection p { border: 2px solid green; }
Bp > section { border: 2px solid green; }
Csection > p { border: 2px solid green; }
Dp.section { border: 2px solid green; }
Attempts:
2 left
💡 Hint
The > selector means direct child, and space means any descendant.
layout
advanced
2:00remaining
What happens to element size with border-box vs content-box?
If an element has width: 200px and border: 10px solid black, what is the total width of the element with box-sizing: border-box vs content-box?
ABoth have 200px total width
Bborder-box: 200px total width; content-box: 220px total width
CBoth have 220px total width
Dborder-box: 220px total width; content-box: 200px total width
Attempts:
2 left
💡 Hint
border-box includes border inside width, content-box adds border outside width.
accessibility
expert
2:00remaining
Which border color choice best supports accessibility?
You want to add a border to a button for focus indication. Which border color choice best supports accessibility for users with low vision?
Aborder: 3px solid #FF0000 (bright red)
Bborder: 3px solid #777777 (medium gray)
Cborder: 3px solid #FFFFFF (white)
Dborder: 3px solid #000000 (pure black)
Attempts:
2 left
💡 Hint
High contrast colors help users with low vision see focus outlines clearly.