Gaelen
Gaelen

Reputation: 315

Is it bad to put <div> elements within the <head> tags?

I want to use conditional comments to make a DIV appear ONLY in browsers with IE7 or older, like this:

<!--[if lt IE 7]>

<div id="browsernotice">
<p>You are using IE7 or less</p>
</div>

<![endif]-->

As far as I understand, conditional comments only work in the header.

Is this bad?

Should I rather use conditional comments to instert a stylesheet that makes an invisible DIV visibility:visible?

Upvotes: 9

Views: 8738

Answers (2)

josh3736
josh3736

Reputation: 145102

Upvotes: 20

Dominic Green
Dominic Green

Reputation: 10258

The best way is to keep the content as is in the document body but instead apply a style sheet for ie that hides the div.

with css

    #browsernotice {
       display:none;
}

And call it with a conditional statement

<!--[if lt IE 7]>
<link href="ie7.css" type="text/css" rel="stylesheet">
<![endif]-->

Upvotes: 7

Related Questions