Defining Block Level Elements
Wednesday, March 7th, 2007I know what an HTML block level element is, but I’m damned if I can say it in a concise, correct, obvious way (which it so happens I need to do in Chapter 4 of Refactoring HTML). In HTML, block level elements include p
, blockquote
, div
, table
, ul
, ol
, dl
, h1
–h6
, and a few others. Generally speaking a block element has a line break before and after it, but that’s really only true in a particualr visual representation. The notion of line breaks doesn’t make a lot of sense in a screen reader, for example.
The HTML 4.0.1 specification defines block elements thusly:
Certain HTML elements that may appear in BODY are said to be “block-level” while others are “inline” (also known as “text level”). The distinction is founded on
several notions:
- Content model
- Generally, block-level elements may contain inline elements and other
block-level elements. Generally, inline elements may contain only data and
other inline elements. Inherent in this structural distinction is the idea that
block elements create “larger” structures than inline elements.- Formatting
- By default, block-level elements are formatted differently than inline
elements. Generally, block-level elements begin on new lines, inline elements
do not. For information about white space, line breaks, and block formatting,
please consult the section on text.- Directionality
- For technical reasons involving the [UNICODE] bidirectional
text algorithm, block-level and inline elements differ in how they inherit
directionality information. For details, see the section on inheritance of text direction.
That’s not a great definition though. These seem more to be consequences rather than defining characteristics of block level elements.
Can anyone offer a more precise definition of block element that does not presume a particular rendering? Just what is a block anyway?