[html] Changing the color of an hr element

After reading all the answers here, and seeing the complexity described, I set upon a small diversion for experimenting with HR. And, the conclusion is that you can throw out most of the monkeypatched CSS you wrote, read this small primer and just use these two lines of pure CSS:

hr {
  border-style: solid;
  border-color: cornflowerblue; /* or whatever */
}

That is ALL you need to style your HRs.

  • Works cross-browser, cross-device, cross-os, cross-english-channel, cross-ages.
  • No "I think this will work...", "you need to keep Safari/IE in mind...", etc.
  • no extra css - no height, width, background-color, color, etc. involved.

Just bulletproof colourful HRs. It's that simpleTM.


Bonus: To give the HR some height H, just set the border-width as H/2.