If a design calls for a graphical horizontal rule, often front end developers will stick in an img tag and call it a day. However, an hr tag would be more semantic - and, most rich text editors for content management systems have a button for the horizontal rule.
These styles allow cross-browser image replacement for horizontal rule. In my implementation, the IE rules needed to be embedded, but it may have simply been a style overriding elsewhere in the stylesheet. Try it in a conditional commented stylesheet first.
The modern method uses background-image to replace the hr, which is defined normally by border. IE works some wonky stuff with list-item and you may have to scoot things around to get it to work just so, but it works!
-
/* ------- EMBEDDED ------- */
-
<!--[if IE]>
-
<style type="text/css">
-
#primary-content hr {
-
display : list-item;
-
list-style : url(/assets/images/wide-rule.gif) inside;
-
filter : alpha(opacity=0);
-
margin-left: -10px;
-
width : 0;
-
}
-
#secondary-content hr{
-
display : list-item;
-
list-style : url(/assets/images/med-rule.gif) inside;
-
filter : alpha(opacity=0);
-
margin-left: 0px;
-
width : 0;
-
}
-
</style>
-
<![endif]-->
-
/* ----- STYLESHEET ----- */
-
-
hr{
-
background:url(short-rule.gif) repeat-x top left;
-
border: 0;
-
}
-
#secondary-content hr{
-
background:url(med-rule.gif) no-repeat top center;
-
border: 0;
-
}

March 6th, 2008 at 9:37 am
Those stinkin' front end developers. Who can trust them?
Very cool. Good to keep in mind. Thx.
April 7th, 2008 at 7:15 pm
HR Image Replacement › Neatly Sliced
HR Image Replacement › Neatly Sliced
April 8th, 2008 at 12:30 am
[...] HR Image Replacement (tags: css) [...]
April 21st, 2008 at 8:17 am
[...] HR Image Replacement with CSS- How to replace the HR tag with an image that works cross browser. [...]
April 22nd, 2008 at 10:18 am
I have tried the code and in firefox works great but in IE 7 it does not repeat the image background.
April 23rd, 2008 at 3:05 am
[...] HR Image Replacement with CSS- 如何使用一张图片来替换HR标签且兼容各大主流浏览器. [...]
April 25th, 2008 at 4:18 am
[...] HR Image Replacement with CSS- How to replace the HR tag with an image that works cross browser. [...]
May 6th, 2008 at 3:07 am
[...] HR Image Replacement with CSS- How to change the HR attach with an ikon that entireness interbreed browser. [...]