On 2006-11-10,
li************@hotmail.com <li************@hotmail.comwrote:
>
>Semantically the <pis meant to contain a paragraph, a single thought
in text (more or less). <divhas 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 <inputelements 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 <inputelements shouldn't be
there because they weren't contained by a <p>
Wrapping the lot with a <pcaused 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!)
Do you mean replace the <p>s with <div>s?
You can always set <divto have the same margins as <phas by default.
e.g.
div.p
{
margin: 1.12em 0;
}
<div class="p">
</div>
for example, although "p" may not be the best name to use.
If you're not using <pto mark a "thought", or something resembling a
"paragraph" in an abstract sense, just use <divinstead.
The fact that the HTML DTD doesn't allow, for example, "block" elements
inside "inline" elements seems to me a bit of an anachronism. In today's
world, HTML isn't supposed to be describing blocks and lines, but
abstract things like "lists" and "tabular data". It's CSS's problem if
it doesn't like a display: block element inside a display: inline
element (although actually it is required to tolerate just about
anything).
HTML has all kinds of requirements about what you can and can't nest
inside what. CSS on the other hand only cares what styles apply, and as
far as it's concerned, tags are nothing more than indices into the bag
of selectors it picks up from the stylesheets and style elements. It
allows any structure you like (although certain things are a bad idea,
like absolutely positioned table cells).
So if you're getting validation errors that are meaningless to you, just
start watering things down into a div soup.
In fact the validation errors probably don't matter a lot in practice
since modern browsers will allow invalid structure anyway and render
according to the styles. But you should probably forget I said that.