Click here to get back home

Why can't I embed divs in a

?

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Why can't I embed divs in a

?

listerofsmeg01 11-10-2006
Posted by listerofsmeg01 on November 10, 2006, 9:40 am
Please log in for more thread options


Sorry if this is a dumb question, but with the following code:

<p>
<div>Block1</div>
<div>Block2</div>
</p>

For xhtml1-strict.dtd, the W3C validator gives:
document type does not allow element "div" here; missing one of
"object", "ins", "del", "map", "button" start-tag.

Whereas with:
<div>
<div>Block1</div>
<div>Block2</div>
</div>

Is it quite happy :-/

I thought both <div> and <p> were block elements, but I'm obviously
missing some fundamental difference :-/


Posted by Benjamin Niemann on November 10, 2006, 9:51 am
Please log in for more thread options


Hello,

listerofsmeg01@hotmail.com wrote:

> Sorry if this is a dumb question, but with the following code:
>
> <p>
> <div>Block1</div>
> <div>Block2</div>
> </p>
>
> For xhtml1-strict.dtd, the W3C validator gives:
> document type does not allow element "div" here; missing one of
> "object", "ins", "del", "map", "button" start-tag.
>
> Whereas with:
> <div>
> <div>Block1</div>
> <div>Block2</div>
> </div>
>
> Is it quite happy :-/
>
> I thought both <div> and <p> were block elements, but I'm obviously
> missing some fundamental difference :-/

Being a 'block' element (vs. 'inline') only tells *where* the element can be
used, not which elements it can contain.
The content model for P only allows inline elements, whereas DIV can contain
both block and inline elements.


HTH

--
Benjamin Niemann
Email: pink at odahoda dot de
WWW: http://pink.odahoda.de/

Posted by Harlan Messinger on November 10, 2006, 9:54 am
Please log in for more thread options


listerofsmeg01@hotmail.com wrote:
> Sorry if this is a dumb question, but with the following code:
>
> <p>
> <div>Block1</div>
> <div>Block2</div>
> </p>
>
> For xhtml1-strict.dtd, the W3C validator gives:
> document type does not allow element "div" here; missing one of
> "object", "ins", "del", "map", "button" start-tag.
>
> Whereas with:
> <div>
> <div>Block1</div>
> <div>Block2</div>
> </div>
>
> Is it quite happy :-/
>
> I thought both <div> and <p> were block elements, but I'm obviously
> missing some fundamental difference :-/

They are both block elements, but all block elements aren't the same in
all ways.

In what way is your chunk of content that includes two block elements
logically a single paragraph? When you read a paragraph in a book or a
report, it's all one block, right?

Posted by Ed Seedhouse on November 10, 2006, 10:09 am
Please log in for more thread options


On 10 Nov 2006 06:40:32 -0800, listerofsmeg01@hotmail.com wrote:

>Sorry if this is a dumb question, but with the following code:
>
><p>
><div>Block1</div>
><div>Block2</div>
></p>
>
>For xhtml1-strict.dtd, the W3C validator gives:
>document type does not allow element "div" here; missing one of
>"object", "ins", "del", "map", "button" start-tag.

Only inline elements are allowed inside a <p> element.

>Whereas with:
><div>
><div>Block1</div>
><div>Block2</div>
></div>
>
>Is it quite happy :-/

Yes, because <div> is designed for grouping block elements.

>I thought both <div> and <p> were block elements, but I'm obviously
>missing some fundamental difference :-/

They are both block elements. That doesn't mean they are equivalent
elements. <ol> and <ul> are block elements too, but they can only
contain <li> elements.

Semantically the <p> is meant to contain a paragraph, a single thought
in text (more or less). <div> has little semantic meaning except to
group other block elements for purposes such as providing a hook for CSS
or javascript.


Posted by listerofsmeg01 on November 10, 2006, 10:29 am
Please log in for more thread options



> Semantically the <p> is meant to contain a paragraph, a single thought
> in text (more or less). <div> has little semantic meaning except to
> group other block elements for purposes such as providing a hook for CSS
> or javascript.

OK, so why is it necessary to contain <input> elements within a
paragraph?

This is what caused my problems in the first place. I had aligned
various controls in my form by encasing them in <div>s and floating
etc.

The W3C validator complained that all my <input> elements shouldn't be
there because they weren't contained by a <p>

Wrapping the lot with a <p> caused the error that started this thread.

I could replace all the <div>s with <p>s, but then all the margins will
be messed up (I don't WANT them in paragraphs!)

Thanks for your help


Similar ThreadsPosted
Problems with divs in IE and Firefox January 26, 2005, 6:49 am
CSS Problem with Nested DIVs October 14, 2005, 4:19 pm
DIVs don't appear in FireFox - any ideas? August 26, 2005, 3:02 pm
margin under floated divs February 14, 2008, 1:06 pm
Embed Tag December 4, 2005, 7:32 pm
Positioning issue with min-width divs January 30, 2008, 2:53 pm
DIVs inside table cells? April 13, 2008, 9:46 am
equivalent for EMBED tag? August 29, 2005, 1:17 am
Trying to sound August 20, 2006, 8:27 pm
embed PDF in page February 22, 2007, 9:43 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap