In HTML, the standard markup language for documents designed to be displayed in a web browser, and HTML element are elements used to define parts of a Web document, so that they are identifiable when a unique classification is necessary. Where other HTML elements such as (paragraph), (emphasis), and so on, accurately represent the Semantic Web of the content, the additional use of and tags leads to better accessibility for readers and easier maintainability for authors. Where no existing HTML element is applicable, and can valuably represent parts of a document so that such as div, span, class, or id can be applied.
represents an inline portion of a document, for example words within a sentence. represents a block-level portion of a document such as a few paragraphs, or an image with its caption. stands for division. The elements allow semantic attributes (e.g. lang), CSS styling (e.g., color and typography), or client-side scripting (e.g., animation, hiding, and augmentation) to be applied.
defines a "division" of the document, a block-level item that is more distinct from elements above and below it than a span of inline material.
I am red and I am blue! |
was introduced to mark up any inline span of text, because "a generic container is needed to carry the LANG and BIDI attributes in cases where no other element is appropriate." It still serves that general purpose, although a much richer range of semantic elements have been defined since then, and there are also many more attributes that may need to be applied.
and elements are used purely to imply a logical grouping of enclosed elements.
There are three main reasons to use and tags with dir or lang="en-US" HTML attribute:
For these reasons, and in support of a more semantic web, attributes attached to elements within HTML should describe their semantic purpose, rather than merely their intended display properties in one particular medium. For example, the HTML in is semantically weak, whereas uses an element to signify emphasis (appearing as text in italics), and introduces a more appropriate class name. By the correct use of CSS, such "warnings" may be rendered in a red, bold font on a screen, but when printed out they may be omitted, as by then it is too late to do anything about them. Perhaps when spoken they should be given extra stress, and a small reduction in speech-rate. The second example is semantically richer markup, rather than merely presentational.
For some years, the World Wide Web Consortium (W3C) has been running a major Semantic Web project designed to make the whole web increasingly useful and meaningful to today's and the future's information systems.
The microformats movement is an attempt to build an idea of semantic classes. For example, microformats-aware software might automatically find an element like and allow for automatic dialing of the telephone number.
Automatic testing tools also may need to navigate web page markup using and elements' id or class attributes. In dynamically generated HTML, this may include the use of page testing tools such as HttpUnit, a member of the xUnit family, and load or stress testing tools such as Apache JMeter when applied to form-driven web sites.
Various HTML element structures available in HTML may be preferable to a home-made mixture of and elements.
For example, this:
which produces
... is usually preferable instead of this:
which produces
Other examples of the semantic use of HTML rather than and elements include the use of elements to divide up a web form, the use of elements to identify such divisions and the use of to identify form elements rather than , or elements used for such purposes.
HTML5 introduced several new elements; a few examples include the , , and elements. The use of semantically appropriate elements provides better structure to HTML documents than or .
|
|