HenryDev
HenryDev

Reputation: 4953

Can I have a div tag inside of the head element in a HTML document?

Just want to know if it's possible to have a div tag inside the head element?

Upvotes: 2

Views: 3405

Answers (1)

markasoftware
markasoftware

Reputation: 12652

No, <div> is not a valid tag to be inside of the <head> tag, since the <head> tag is only meant to be for metadata (such as title and page description), scripts, styles, and other stuff which isn't meant to be displayed. Although putting it in the <head> works, it's horrible to do so, and you shouldn't put it there (and the specification says that doing that is not valid HTML. Thanks @t.niese); it's invalid HTML

Also, there is no difference between using " or ' for attribute values (such as id in your case), it's just what you prefer. And yes, using ' is completely valid. I like doing that, since I don't have to hold shift, but it's completely up to you.

Upvotes: 6

Related Questions