Steve 25

I'm getting this warning in the Visual Studio IDE. Is this true? Why is this the case, both are block elements in xhtml, no?

How can I determine which doctypes this error applies to? Does the above apply to both xhtml strict and transitional?

  • I can't think of any good reason to nest a div inside a header. What exactly are you trying to do? Nathan Duran about 7 years ago
  • I meant heading rather than header of course. Nathan Duran about 7 years ago
  • A div within a header looked weird to me too. It was an input button within a div. I took out the div and got what I wanted. I guess my question really is, is there a set of rules I can lookup in terms of what can be nested in what. What's allowed and what's not? I just assumed you could always nest a block within a block. Obviously not. Steve about 7 years ago

3 answers


A heading is a block element but can only contain inline elements. There's no difference for strict or transitional. When you're unsure what an element can contain, these pages can help you out for Block elements and Inline elements.

Answered about 7 years ago by Alex Demeyere

If you need something to change the format inside a header (h1,h2,etc.), try a <span>. Block elements aren't allowed.

Answered about 7 years ago by Brendan Long

I've used this reference made from at guy of the WASP project alot back in the days to learn and remind me of whats standards specs say.

Answered about 7 years ago by Jens Hedqvist