|
Posted by Jukka K. Korpela on 01/09/07 10:07
Scripsit dorayme:
>> Are there any circumstances where I can put a <div> inside a <p> or
>> is this just part of using a Strict Doctype?
>
> No you cannot do this.
You cannot, and the simple reason is that none of the HTML document types
allows that. Well, you _can_ do it, but the markup is then invalid and the
results are more or less unpredictable, especially in future browser
versions.
But there's no "deeper" reason to this. It's just a matter of HTML syntax,
which was defined somewhat arbitrarily in this respect, perhaps partly for
technical reasons (to make the world safe for simplistic browsers).
The OP has solved the problem nicely by putting the image and the caption in
a div element _before_ the paragraph and using CSS to make it appear the
same way you could do for a simple image using <img ... align="right">. One
could also use a two-cell table, with the image and the caption text in
separate cells and with align="left". It would be valid as Transitional,
though not acceptable by all Purists' standards.
> But can you think of a circumstance in
> which you had a paragraph which suddenly broke out into a
> rectangle underneath with something in it like a pic or movie and
> then continued after with text and still be rightly a paragraph
> in the ordinary understanding of this item? Surely not.
I can, without problems. Actually I often run into such situations. For
example, I might find myself writing something that needs to be illustrated
with an image or a long formula or a multi-line code snippet inside a
paragraph, since the explanation continues after it in a natural way. Surely
I can use just <img ...> for an image, and I can use <br><img ...><br> to
make it appear in a line of its own. But why should things get radically
different if the image needs a caption below it? I _can_ fool the syntax
restrictions by using <br><span class="image"><img ...><br><span
class="caption">caption text</span><br> and some CSS to style the construct,
but that would really be just a workaround in a situation where I _wanted_
to use <div>. (Well, I _really_ wanted to use <fig>, but they never added it
to the specifications and never implemented it.)
To summarize: Live with the restrictions, but there's no need to make the
restrictions a virtue.
--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/
Navigation:
[Reply to this message]
|