Contents
This section of the specification discusses some HTML elements andattributes that may be used for visual formatting of elements. Many of them aredeprecated.
Attribute definitions
This attribute sets the background color of the canvas for the document body(theBODY element) or for tables (theTABLE,
This attribute has beendeprecatedin favor of style sheets for specifying background color information.
It is possible to align block elements (tables, images, objects, paragraphs,etc.) on the canvas with thealign attribute. Although thisattribute may be set for many HTML elements, its range of possible valuessometimes differs from element to element. Here we only discuss the meaning ofthe align attribute for text.
Attribute definitions
The default depends on the base text direction. For left to right text, thedefault isalign=left, while for right to left text, the defaultisalign=right.
DEPRECATED EXAMPLE:
This example centers a heading on the canvas.
<H1 align="center"> How to Carve Wood </H1>
Using CSS, for example, you could achieve the same effect as follows:
<HEAD> <TITLE>How to Carve Wood</TITLE> <STYLE type="text/css"> H1 { text-align: center} </STYLE><BODY> <H1> How to Carve Wood </H1>
Note that this would center allH1 declarations. You could reducethe scope of the style by setting theclass attribute on the element:
<HEAD> <TITLE>How to Carve Wood</TITLE> <STYLE type="text/css"> H1.wood {text-align: center} </STYLE><BODY> <H1> How to Carve Wood </H1>
DEPRECATED EXAMPLE:
Similarly, to right align a paragraph on the canvas with HTML'salignattribute you could have:
<P align="right">...Lots of paragraph text...
which, with CSS, would be:
<HEAD> <TITLE>How to Carve Wood</TITLE> <STYLE type="text/css"> P.mypar {text-align: right} </STYLE><BODY> <P>...Lots of paragraph text...
DEPRECATED EXAMPLE:
To right align a series of paragraphs, group them with theDIV element:
<DIV align="right"> <P>...text in first paragraph... <P>...text in second paragraph... <P>...text in third paragraph...</DIV>
With CSS, the text-align property is inherited from the parent element, youcan therefore use:
<HEAD> <TITLE>How to Carve Wood</TITLE> <STYLE type="text/css"> DIV.mypars {text-align: right} </STYLE><BODY> <DIV> <P>...text in first paragraph... <P>...text in second paragraph... <P>...text in third paragraph... </DIV>
To center the entire document with CSS:
<HEAD> <TITLE>How to Carve Wood</TITLE> <STYLE type="text/css"> BODY {text-align: center} </STYLE><BODY>...the body is centered...</BODY>
TheCENTER element isexactly equivalent to specifying theDIV element with thealignattribute set to "center".TheCENTER element isdeprecated.
Images and objects may appear directly "in-line" or may be floated to oneside of the page, temporarily altering the margins of text that may flow oneither side of the object.
Thealign attribute for objects, images, tables, frames, etc., causesthe object to float to the left or right margin. Floating objects generallybegin a new line. This attribute takes the following values:
DEPRECATED EXAMPLE:
The following example shows how to float anIMG element to the current left margin of the canvas.
<IMG align="left" src="http://foo.com/animage.gif" alt="my boat">
Some alignment attributes also permit the "center" value, which does notcause floating, but centers the object within the current margins. However, forP and
Another attribute, defined for theBR element, controlstext flow around floating objects.
Attribute definitions
Consider the following visual scenario, where text flows to the right of animage until a line is broken by aBR:
********* -------| | -------| image | --<BR>| |*********
If theclear attribute is set tonone, the linefollowingBR will begin immediately below it at the right margin ofthe image:
********* -------| | -------| image | --<BR>| | ------*********
DEPRECATED EXAMPLE:
If theclear attribute is set toleft orall, the next line will appear as follows:
********* -------| | -------| image | --<BR clear="left">| | *********-----------------
Using style sheets, you could specify that all line breaks should behavethis way for objects (images, tables, etc.) floating against the left margin.With CSS, you could achieve this as follows:
<STYLE type="text/css">BR { clear: left }</STYLE>
To specify this behavior for a specific instance of theBRelement, you could combine style information and theid attribute:
<HEAD>...<STYLE type="text/css">BR#mybr { clear: left }</STYLE></HEAD><BODY><P>...********* -------| | -------| table | --<BR>| | *********-----------------...</BODY>
The following HTML elements specify font information. Although they arenot alldeprecated, their use isdiscouraged in favor of style sheets.
<!ENTITY % fontstyle "TT |I |B |BIG |SMALL"><!ELEMENT (%fontstyle;|%phrase;) - - (%inline;)*><!ATTLIST (%fontstyle;|%phrase;)%attrs; --%coreattrs,%i18n,%events -- >
Start tag:required, End tag:required
Attributes defined elsewhere
Rendering of font style elements depends on the user agent. The following isan informative description only.
The following sentence shows several types of text:
<P><b>bold</b>,<i>italic</i>, <b><i>bold italic</i></b>, <tt>teletype text</tt>, and<big>big</big> and <small>small</small> text.
These words might be rendered as follows:
It is possible to achieve a much richer variety of font effects using stylesheets. To specify blue, italic text in a paragraph with CSS:
<HEAD><STYLE type="text/css">P#mypar {font-style: italic; color: blue}</STYLE></HEAD><P>...Lots of blue italic text...
Font style elements must be properly nested. Rendering of nested font styleelements depends on the user agent.
FONT andBASEFONT aredeprecated.
See theTransitional DTD forthe formal definition.
Attribute definitions
Attributes defined elsewhere
TheFONT element changes the font size and color for text in itscontents.
TheBASEFONT element sets the base font size (using the
DEPRECATED EXAMPLE:
The following example will show the difference between the seven font sizesavailable withFONT:
<P><font size=1>size=1</font><font size=2>size=2</font><font size=3>size=3</font><font size=4>size=4</font><font size=5>size=5</font><font size=6>size=6</font><font size=7>size=7</font>
This might be rendered as:
The following shows an example of the effect of relative font sizes using abase font size of 3:
The base font size does not apply to headings, except where these aremodified using the
<!ELEMENTHR - O EMPTY -- horizontal rule --><!ATTLIST HR%attrs; --%coreattrs,%i18n,%events -- >
Start tag:required, End tag:forbidden
Attribute definitions
The default isalign=center.
Attributes defined elsewhere
TheHR element causes a horizontal rule to be rendered by visual useragents.
The amount of vertical space inserted between a rule and the content thatsurrounds it depends on the user agent.
DEPRECATED EXAMPLE:
This example centers the rules, sizing them to half the available widthbetween the margins. The top rule has the default thickness while the bottomtwo are set to 5 pixels. The bottom rule should be rendered in a solid colorwithout shading:
<HR width="50%" align="center"><HR size="5" width="50%" align="center"><HR noshade size="5" width="50%" align="center">
These rules might be rendered as follows: