-
Hajipur, Bihar, 844101
CSS Borders are used to define the outline around an HTML element.
You can set the style, width, and color of the border.
element {
border: 2px solid black;
}
2px
→ border width
solid
→ border style
black
→ border color
Available values for border-style
:
none
solid
dashed
dotted
double
groove
ridge
inset
outset
Example:
div {
border-style: dotted;
}
border-top: 2px solid red;
border-right: 3px dashed blue;
border-bottom: 1px solid black;
border-left: 4px double green;
div {
border-width: 3px;
border-style: solid;
border-color: orange;
}
div {
border: 3px dotted blue;
}
✅ Combines width, style, and color into a single line.
Use the border-radius
property:
div {
border: 2px solid gray;
border-radius: 10px;
}
✅ Makes the border corners rounded.
Q1. Add a solid black border of 2px around a <div>
.
Q2. Apply a dashed red border to all <p>
elements.
Q3. Set only the top border of a <h1>
to 3px dotted green.
Q4. Use shorthand to set a double 4px blue border.
Q5. Write a rule to set different border styles on each side of an image.
Q6. Add a 5px groove border to an element with class .box
.
Q7. Apply a ridge border with color #ccc
to all <section>
elements.
Q8. Make the corners of a container rounded using border-radius: 15px
.
Q9. Add a border only on the bottom of all <h2>
elements.
Q10. Combine border-width
, border-style
, and border-color
using separate properties.
Q1: Which CSS property sets a border around an element?
Q2: What does border: 2px solid red; do?
Q3: What value makes a border rounded?
Q4: Which of the following is a valid border style?
Q5: How do you apply only a top border?
Q6: What does border: none; do?
Q7: Which property defines the thickness of the border?
Q8: Which is a valid way to make all four borders dashed?
Q9: What is the default border style?
Q10: What will border-radius: 50%; do?