I want to change the thickness of my horizontal rule (
)in CSS. I know it can be done in HTML like so -
I would recommend setting the HR
itself to be 0px
high and use its border to be visible instead. I have noticed that when you zoom in and out (ctrl + mouse wheel) the thickness of HR
itself changes, while when you set the border it always stays the same:
hr {
height: 0px;
border: none;
border-top: 1px solid black;
}
I believe the best achievement for styling <hr>
tag is as follow:
hr {
color:#ffffd;
background-color:
#ffffd; height:1px;
border:none;
max-width:100%;
}
And for the HTML code just add: <hr>
.
I was looking for shortest way to draw an 1px line, as whole load of separated CSS is not the fastest or shortest solution.
Up to HTML5, the WAS a shorter way for 1px hr: <hr noshade> but.. The noshade attribute of <hr> is not supported in HTML5. Use CSS instead. (nor other attibutes used before, as size, width, align)...
Now, this one is quite tricky, but works well if most simple 1px hr needed:
Variation 1, BLACK hr: (best solution for black)
<hr style="border-bottom: 0px">
Output: FF, Opera - black / Safari - dark gray
Variation 2, GRAY hr (shortest!):
<hr style="border-top: 0px">
Output: Opera - dark gray / FF - gray / Safari - light gray
<hr style="border: none; border-bottom: 1px solid red;">
Output: Opera / FF / Safari : 1px red.