Forum Moderators: open

Message Too Old, No Replies

Help understanding HTML DTD

....about inline and block elements

         

paolodina

3:19 pm on Dec 19, 2005 (gmt 0)

10+ Year Member



Looking at the HTML Document Type Definition, is it possible to say if an element is an inline element or a block element? If yes, how?

Thanks

tedster

3:32 pm on Dec 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As far as I know, every DTD makes the same default assuptions about which elements are block and which are inline. However, an author can override this assignment in the CSS anywhere in the cascade.

[w3.org...]

paolodina

4:11 pm on Dec 19, 2005 (gmt 0)

10+ Year Member



I will rephrase my question: how is it possible to know if an element is inline or block, using official w3c resources? (I thought that dtd would be the most authoritative place to put these kind of stuffs)

I'd like to point out that I'm still reading the specification, so there are many possibilities that the question is covered there. I'm currently asking here because I need to have this information quickly, before ending to read the w3c material.

Thanks again

tedster

4:28 pm on Dec 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This page lists the elements in HTML 4.01 strict and shows after each one either %inline or %block

[w3.org...]

paolodina

5:00 pm on Dec 19, 2005 (gmt 0)

10+ Year Member



%inline and %block are two entities that refer to the element's content (if any) "nature", they don't say anything about the nature of element itself.

If you mean that looking at how %inline and %block are defined I can obtain inline and block elements, that is not true. In fact some elements (i.e. LI) are not listed as inline, neither as block. This is the reason for my initial question!

bedlam

6:04 pm on Dec 19, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



When you say that:

%inline and %block are two entities that refer to the element's content (if any) "nature", they don't say anything about the nature of element itself.

...you're not quite right. It is true that, when you see '%inline' and '%block' (or '%flow'), in an ELEMENT in the dtd, the spec is describing the permissible content of the element. But the block, inline and flow ENTITY declarations do specify the elements that belong to each set:

(from the DTD [w3.org])

<!--
HTML has two basic content models:

%inline; character level elements and text strings
%block; block-like elements e.g. paragraphs and lists
-->

<!ENTITY % block
"P ¦ %heading; ¦ %list; ¦ %preformatted; ¦ DL ¦ DIV ¦ NOSCRIPT ¦
BLOCKQUOTE ¦ FORM ¦ HR ¦ TABLE ¦ FIELDSET ¦ ADDRESS">

I'm not completely sure why list-items are not explicitly marked as either block or inline, but since they can contain either block or inline content:

<!ELEMENT LI - O (%flow;)* -- list item -->

<!ENTITY % flow "%block; ¦ %inline;">

...it's strongly implied that it's a block-level element.

I suspect that the reason it's not laid out explicitly in the HTML spec has to do with the fact that the CSS spec has alternatives besides 'inline' and 'block' [w3.org]...and it turns out the 'list-item' entry confirms that list items do behave as block level elments (i.e. they "...generate a principal block box.")

-B