Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Removing the <hr /> border styling on IE

Why is it the simple things that IE manages to mess up the most? Anyway I want to replace a normal hr line with a single image a bit like the - § - symbol (on its side). Trying to make it look elegant :)

It appears the only way to actually get rid of the border in IE though is to set the color: css value. Doing this will override whatever is set as background-image unfortunately and make the whole hr the parameter for color.

It's not possible to wrap it in a div or even really apply a class to it as the client that will be using the site is using a wysiwyg text editor which I don't really relish hacking to insert a div wrapped hr.

I am one step away from adding a div block wrapper with jquery, but that seems fundamentally wrong (shotgun vs walnut) - any suggestions?

like image 888
Meep3D Avatar asked Jul 01 '09 18:07

Meep3D


People also ask

How do I hide HR line in HTML?

.. display: none; would just hide it and the 1px of vertical space that the poster wants will be gone.

How do I change the color of my HR tag line?

Answer: Use the CSS background-color Property You can simply use the CSS background-color property in combination with the height and border to the change the default color an <hr> element.

How do I change a dotted line to HR?

You could just have <hr style="border-top: dotted 1px;" /> . That should work.


3 Answers

http://blog.neatlysliced.com/2008/03/hr-image-replacement/

<style type="text/css">
    hr {
       background: url(http://placekitten.com/800/100) no-repeat;
       border: 0;
       height: 100px;
       width: 100%;
    }
</style>
<!--[if IE 7]>
<style type="text/css">
    hr {
        display : list-item;
        list-style : url(http://placekitten.com/800/100) inside;
        filter : alpha(opacity=0);
        margin-left: -10px;
        width : 0;
    }
</style>
<![endif]-->

See it working here: jsFiddle

like image 69
Detect Avatar answered Sep 28 '22 05:09

Detect


Well, you could just insert the image directly and not use an <hr /> tag. However, I'm fairly certain you can get rid of the offending border by just changing it to be the color of your background. I mean, it's not actually gone, but at least it's hiding:

hr{
   border: #XXXXXX;
}
like image 31
Peter Avatar answered Sep 28 '22 05:09

Peter


IE8, fortunately does things properly. So there is hope in 12 years.

If your background color is solid, just define the border as that color and it disappears.

like image 39
Ryan Florence Avatar answered Sep 28 '22 03:09

Ryan Florence