Welcome!

And don't forget to edit your signature & profile.

 

Icon

Statistics

  • Total posts 23326
  • Total topics 4050
  • Total members 5576
  • Our newest member
    feha

TOP POSTERS

hr styling in ie6 & ie7

All problems and developments related to (X)HTML-markup and stylesheets are discussed and resolved here.
   

hr styling in ie6 & ie7

Postby danatello » Sun Oct 18, 2009 6:29 pm

Hey,

So in trying to keep my markup clean I am styling a hr element using a background image, in ie6 and ie7 the hr has a border that I can't get rid of, anything obvious I might be missing?
danatello
 
Posts: 7
Joined: Mon Feb 09, 2009 2:26 pm
   

   

Re: hr styling in ie6 & ie7

Postby jarek » Mon Oct 19, 2009 12:06 pm

IE has a bug with <hr> so the only solution is something like this:

Code: Select all
<div style="height:20px;background: #fff url(background.gif) no-repeat center;"><hr style="display:none;" /></div>
Front-end web developer with an admixture of web designer.
http://jarek.olsztyn.pl
User avatar
jarek
Smashing <frame>
 
Posts: 12
Joined: Sun Oct 18, 2009 8:14 am
Location: Poland
   

   

Re: hr styling in ie6 & ie7

Postby danatello » Mon Oct 19, 2009 12:11 pm

Well, isn't that just horrible. Cheers!
danatello
 
Posts: 7
Joined: Mon Feb 09, 2009 2:26 pm
   

   

Re: hr styling in ie6 & ie7

Postby Andy » Mon Oct 19, 2009 12:32 pm

jarek wrote:so the only solution is something like this


That is incorrect. There is another solution.

You apply the background as you usually do:

Code: Select all
hr {
   background: url(hr.png) no-repeat;
   border: 0;
   height: 40px;
}


then you serve up a special version to IE6 & 7:

Code: Select all
display: list-item;
list-style: url(hr.png) inside;
text-align: left;
filter : alpha(opacity=0);


You could do this through a conditional comment or the Star HTML hack.
Andy
Smashing <h5>
 
Posts: 1025
Joined: Tue Sep 30, 2008 6:42 pm
Location: Sweden
   

   

Re: hr styling in ie6 & ie7

Postby danatello » Mon Oct 19, 2009 12:37 pm

Will try this out using the * hack, thanks alot!
danatello
 
Posts: 7
Joined: Mon Feb 09, 2009 2:26 pm
   

   

Re: hr styling in ie6 & ie7

Postby Andy » Mon Oct 19, 2009 1:40 pm

danatello wrote:Will try this out using the * hack, thanks alot!


You're welcome.

The only negative thing about this technique is that you cannot use CSS sprites, which kind of sucks. Anyway, good luck.
Andy
Smashing <h5>
 
Posts: 1025
Joined: Tue Sep 30, 2008 6:42 pm
Location: Sweden
   

   

Re: hr styling in ie6 & ie7

Postby danatello » Thu Oct 22, 2009 3:18 pm

Yeah unfortunately I can't use sprites anyway (textured background [not my choice!]).

Is there any reason why IE needs it to be like that?
danatello
 
Posts: 7
Joined: Mon Feb 09, 2009 2:26 pm
   

   

Re: hr styling in ie6 & ie7

Postby Andy » Thu Oct 22, 2009 3:32 pm

danatello wrote:Is there any reason why IE needs it to be like that?


I can offer you two explanations:

1. Internet Explorer 7 and below does not consider the border around a HR tag to actually be a border. This workaround must therefore be applied to overcome this discrepancy.

2. The IE team fucks up everything they touch.
Andy
Smashing <h5>
 
Posts: 1025
Joined: Tue Sep 30, 2008 6:42 pm
Location: Sweden
   


Return to CSS and (X)HTML



Who is online

Users browsing this forum: No registered users and 1 guest