HTML and CSS Reference
In-Depth Information
Written Communication: Logical and Physical Interpretation of Elements
As you learn more HTML, you'll notice some overlap in how browsers display certain ele-
ments. To display italicized text, you could use the <dfn> , <em> , <i> , or <var> tags; or if
you wanted to italicize an entire block of text, you could use the <address> tag. However,
browsers differ in how they display elements, so you should not rely on the way any
browser or group of browsers commonly displays an element.
In addition, it's important to distinguish between the way a browser displays an ele-
ment, and the purpose of the element in the document. Although it can be tempting to
ignore this difference, your HTML code benefits when you respect that distinction because
search engines often look within specific elements for information. For example, a search
engine may look for the address element to find contact information for a particular Web
site. It would be confusing to end users if you used the address element to simply italicize
a block of text. Web programmers can also use elements to extract information from a
page. For example, a JavaScript program could automatically generate a bibliography from
all of the citations listed within a Web site by looking for occurrences of the cite element.
The best practice for communicating the purpose of your document is to use HTML to
mark content but not to rely on HTML to format that content. Formatting should be done
solely through style sheets, using either the internal style sheets built into browsers or
through your own customized styles.
Using the Generic Elements div and span
Most of the page elements you've examined have a specifi c meaning. However, some-
times you want to add an element that represents a text block or a string of inline text
without it having any other meaning. HTML supports two such generic elements: div
and span . The div element is used to mark general grouping content and has the follow-
ing syntax:
<div> content </div>
The span element, which is used to mark general text-level content, has the following
<span> content </span>
Browsers recognize both elements but do not assign any default format to content
marked with these elements. This frees Web authors to develop styles for these elements
without worrying about overriding any styles imposed by browsers. Note that the main
use of the div element to mark sections of the page has been superseded in HTML5 by
the sectional elements such as header and article ; however, you will still encounter
the div element in many current and older Web sites.
Search WWH ::

Custom Search