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 over 6 years ago
  • I meant heading rather than header of course. Nathan Duran over 6 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 over 6 years ago

3 answers

4
points

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 over 6 years ago by Alex Demeyere
2
points

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

Answered over 6 years ago by Brendan Long
1
point

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 over 6 years ago by Jens Hedqvist