65.9K
CodeProject is changing. Read more.
Home

Writing conditional logic via CSS

starIconemptyStarIconemptyStarIconemptyStarIconemptyStarIcon

1.00/5 (1 vote)

Mar 30, 2010

CPOL
viewsIcon

11341

Sometimes we face some UI problem like for example We need a line break in Internet Explorer 7. But we don't need that for other browser.This can be done in many ways but i got a interesting solution of this.write a CSS like this.breakOnlyInIE7{ display:none;...

Sometimes we face some UI problem like for example We need a line break in Internet Explorer 7. But we don't need that for other browser. This can be done in many ways but i got a interesting solution of this. write a CSS like this
.breakOnlyInIE7
{
 display:none;
 *display:block;
}
and write a new line html code like below
<br class="breakOnlyInIE7" /> 
That is our very known <br /> tag with a CSS class containing IE7 specific CSS Hack. The above code will render <br /> tag only in IE7 and for rest of the browser no new line tag will be rendered! ;)