Elements
Elements
are the
basis of CSS display. In HTML, the most common elements are easily
recognizable, such as p, table,
span, a, and
div. In XML languages, the elements are defined by
the language’s
Document Type Definition (DTD). Every
single element in a document plays a part in its presentation. In CSS
terms, at least as of CSS2.1, that means each element generates a box
that contains the element’s content.
Replaced and Nonreplaced Elements
Although CSS depends on elements, not all elements are created
equally. For example, images and paragraphs are not the same type of
element, nor are span and div.
In CSS, elements generally take two forms: replaced and nonreplaced.
The two types are explored in detail in Chapter 7, which covers the particulars of the box
model, but I’ll address them briefly here.
Replaced elements
Replaced elements
are
those where the element’s content is replaced by
something that is not directly represented by document content. The
most familiar XHTML example is the img element,
which is replaced by an image file external to the document itself.
In fact, img has no actual content, as you can see
by considering a simple example:
<img src="howdy.gif" />
This code snippet contains no actual content—only an element
name and an attribute. The element presents nothing unless you point
it to some external content (in this case, an image specified by the
src attribute). The input element is also replaced by a radio button, checkbox, or text input box, depending ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access