what are <hr> tags? / intro
hr
is an html element that appears on screens as a divider. its useful for helping you seperate content, i.e. large bodies of texts. its purpose is to define thematic breaks/change of content in your html document. by default, they appear to be a line with a gray inset border.
this short guide will detail some methods to styling them which you can use to better fit the theme of your pages ☺
of course not every possible way you could style them w css is listed here; the purpose of this is more just a 'bounce pad' where you can combine/add to what ive compiled here
p.s. it stands for 'horizontal rule'basic border styling
i find the hr
tag's default styling really ugly and not suited for most pages kek. the simplest way to style it is just to change its default border style.
taller/"thicker" border
hr
, at its core, is just an empty div
acting as a line; its not just a line, but a very thin box. we can change its width to be taller by simply giving it a height value.
if you want a border with a rounded border, we can do so by defining a background property and using that as a "line" while having rounded edges at the same time.
image/background borders
by making our borders taller by simply defining the height of hr
, we can also give the hr a backgrond image value so the border image is "inclosed" in a semantic tag and isnt just an image. this is good as just a good coding practice (i think) and accessibility (i think)
!!of course theres instances were image borders are more suited!! but i find the most frequent times ill use an image border itll be for the same purpose hr
was made for
tip: set the height of the hr
to the image height
since hr
can be customized just like a div
any background type can be used (duh) like linear gradients.
thinner lines look really good with gradients imo ☺