Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / web / HTML

Writing conditional logic via CSS

1.00/5 (1 vote)
30 Mar 2010CPOL 1  
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

<code>.breakOnlyInIE7
{
 display:none;
 *display:block;
}</code>



and write a new line html code like below

<code><br class="breakOnlyInIE7" /></code> 


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! ;)

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)