HTML and CSS Reference
In-Depth Information
Inline elements: a , abbr , acronym , b , bdo , br , cite , code , dfn , em , img , input , label , q , samp , select ,
span , strong , sub , sup , textarea , var
Miscellaneous elements: button , del , iframe , ins , map , object , script
Context-limited elements: li , dt , dd , tr , th , td , tbody , input , select
Raw text; a.k.a. PCDATA
A block element represents a distinct section that is separated from the elements that precede and follow it. In
visual renderings, this separation usually takes the form of a hard line break. In strict XHTML, the body of the
page can only contain block elements.
Most block elements can nest. That is, a block can contain other blocks. However, there are a couple of notable
exceptions: p and pre .
A p element represents a paragraph. However, unlike other block-level elements, a p may not contain another p
or another block element such as blockquote . It can only contain plain text and inline elements. It is in some
sense the lowest block-level element.
The pre element is also special in this way. It can contain inline elements, but not other block elements.
Inline elements such as span , strong , img , and a are contained within some block. In transitional XHTML, this
block may be implicit, but in strict XHTML, this block must be an explicit block-level element. Inline elements
can usually contain other inline elements (though there are exceptions), but they may not contain block
elements. Inline elements may wrap from one line to the next, but they do not cause line breaks as long as
there's space left on the current line.
A few miscellaneous elements such as object and ins can be used as either inline or block elements. However,
if they're used as inline elements (i.e., they're inside a paragraph or pre ), they cannot contain a block element.
Finally, a few context-sensitive elements appear in certain parent elements but not others. For instance, an li
element must be a child of a ul or ol element. An li element anywhere else is invalid. A td element must be a
child of a tr element, which must itself be a child of a tbody or table element. These elements may not appear
outside their defined parent elements.
If any elements appear where they don't belong, the validator will tell you about them. There are actually two
styles of error message you may see. Some validators tell you that the parent element has the wrong child. For
example, xmllint provides this error message:
example.html:12: element p: validity error : Element div is
not declared in p list of possible children
Others tell you that the child has the wrong parent. A few may tell you both. Either way the meaning is the
The most common variation of this problem is an inline element without a parent—in particular, raw text that is
an immediate child of the body element:
<h1>Welcome to Acme!</h2>
Your one-stop source for rockets, explosives, anvils,
Search WWH ::

Custom Search