Performance: Border styles
Border styles affect the paint phase of rendering and can impact page load speed if overused or complex.
Jump into concepts and practice - no test required
div { border: 1px solid red; }div { border: 5px double red; }| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| 1px solid border | none | none | low paint cost | [OK] Good |
| 5px double border | none | none | high paint cost | [X] Bad |
| 3px dashed border with border-radius | none | none | very high paint cost | [X] Bad |
| 2px solid border with small border-radius | none | none | moderate paint cost | [!] OK |
border-style value creates a solid continuous line around an element?border-style property controls the line style of borders. Common values include solid, dotted, dashed, and double.solid value creates a continuous, unbroken line around the element.div?dashed. Incorrect values like dash, dashes, or dot are not recognized.border-style: dashed; correctly applies a dashed border style to the element.p {
border-width: 3px;
border-style: double;
border-color: blue;
}double border style draws two parallel lines with a small space between them. The total thickness is controlled by border-width.div {
border-style: solid;
border-width: 0;
border-color: red;
}div.card { border-style: solid; } sets this correctly.div.card:hover { border-style: dotted; } changes the border style to dotted when the mouse is over the card.