How to Style an HTML : A Clean, Copy-Paste CSS Pattern
Most browsers render an HTML <hr> as a horizontal rule, but the default styling is not always what you want in a real interface. A common first attempt is to change height or color and move on. That can leave the browser's default border in place, which is why a divider may look thicker, doubled, or different from the design you expected. Here is a small, reusable pattern that makes the result predictable. Start with a stable divider class Add this HTML wherever a thematic break between sections makes sense: <hr class= "section-divider" > Then add this CSS: hr .section-divider { border : 0 ; border-top : 2px dashed #ca8a04 ; width : 60% ; max-width : 42rem ; margin : 2rem auto ; } This creates a centered, dashed divider that stays readable on both narrow and wide layouts. Why this pattern works There are four important choices in that snippet: border: 0 removes the browser's default border before you add your own style. border-top gives you one visible line to control. width and max-width keep the divider from becoming excessively long. margin: 2rem auto adds vertical breathing room and centers the element. The hr element is also semantic. It represents a thematic break in content, such as a shift from one topic to another. That makes it a better choice than a random empty div when the line actually separates ideas. Three useful variations Once the base pattern is in place, changing the appearance is straightforward. A quiet solid divider Use this when the line should support the layout without attracting attention: hr .section-divider { border : 0 ; border-top : 1px solid #cbd5e1 ; width : 100% ; margin : 1.5rem 0 ; } A dotted divider A dotted rule works well for lightweight notes, forms, or playful interfaces: hr .section-divider { border : 0 ; border-top : 2px dotted #94a3b8 ; width : 50% ; margin : 2rem auto ; } A stronger double divider For an editorial section break, use a double border with enough thickness for the two lines to remain visible: hr .section-div