Movatterモバイル変換


[0]ホーム

URL:


 previous  next  contents  elements  attributes  index

15 Alignment, font styles, and horizontal rules

Contents

  1. Formatting
    1. Background color
    2. Alignment
    3. Floating objects
  2. Fonts
    1. Font style elements: theTT,I,B,BIG,SMALL,STRIKE,S, andU elements
    2. Font modifier elements:FONT andBASEFONT
  3. Rules: theHRelement

This section of the specification discusses some HTML elements andattributes that may be used for visual formatting of elements. Many ofthem aredeprecated.

15.1 Formatting

15.1.1Background color

Attribute definitions

bgcolor =color[CI]
Deprecated.This attribute sets the background color for the document body or table cells.

This attribute sets the background color of the canvas for thedocument body (theBODY element) or fortables (theTABLE,TR,TH, andTD elements). Additional attributes for specifyingtext color can be used with theBODYelement.

This attribute has beendeprecated in favor of style sheets forspecifying background color information.

15.1.2Alignment

It is possible to align block elements (tables, images, objects,paragraphs, etc.) on the canvas with thealignattribute. Although this attribute may be set for many HTML elements, itsrange of possible values sometimes differs from element to element. Here weonly discuss the meaning of the align attribute for text.

Attribute definitions

align =left|center|right|justify[CI]
Deprecated. This attribute specifies the horizontalalignment of its element with respect to the surrounding context.Possible values:
  • left: text lines are rendered flush left.
  • center: text lines are centered.
  • right: text lines are rendered flush right.
  • justify: text lines are justified to both margins.

The default depends on the base text direction. For left toright text, the default isalign=left, while forright to left text, the default isalign=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 allH1declarations. You could reduce the 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'salign attribute 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 inheritedfrom the parent element, you can 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>

TheCENTERelement is exactly equivalent to specifying theDIV element with thealign attribute set to "center".TheCENTER element isdeprecated.

15.1.3Floating objects

Images and objects may appear directly "in-line" or may be floated toone side of the page, temporarily altering the margins of text that mayflow on either side of the object.

Float an object 

Thealign attribute for object, images,tables, frames, etc., causes the object to float to the left or right margin.Floating objects generally begin a new line. This attribute takes thefollowing values:

DEPRECATED EXAMPLE:
The following example shows how to float anIMG element to the currentleft margin of the canvas.

<IMG align="left" src="http://foo.com/animage.gif" alt="my boat">

Some alignment attributes also permit the "center" value, whichdoes not cause floating, but centers the object within the currentmargins. However, forP andDIV, the value "center" causes thecontents of the element to be centered.

Float text around an object 

Another attribute, defined for theBRelement, controlstext flow around floating objects.

Attribute definitions

clear =none|left|right|all[CI]
Deprecated.Specifies where the next line should appear in a visual browser after the line break caused by this element. This attribute takes into account floating objects (images, tables, etc.). Possible values:
  • none: The next line will begin normally.This is the default value.
  • left: The next line will begin at nearestline below any floating objects on the left-hand margin.
  • right: The next line will begin at nearestline below any floating objects on the right-hand margin.
  • all: The next line will begin at nearestline below any floating objects on either margin.

Consider the following visual scenario, where text flows to the rightof an image until a line is broken by aBR:

*********  -------|       |  -------| image |  --<BR>|       |*********

If theclear attribute is set tonone, the line followingBRwill begin immediately below it at the right margin of the image:

*********  -------|       |  -------| image |  --<BR>|       |  ------*********

DEPRECATED EXAMPLE:
If theclear attribute is set toleft orall, next line will appear asfollows:

*********  -------|       |  -------| 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 leftmargin. 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 theBR element, you could combine style informationand theid attribute:

<HEAD>...<STYLE type="text/css">BR#mybr { clear: left }</STYLE></HEAD><BODY><P>...*********  -------|       |  -------| table |  --<BR>|       |  *********-----------------...</BODY>

15.2Fonts

The following HTML elements specify font information. Althoughthey are not alldeprecated, their use is discouraged in favor of stylesheets.

15.2.1Font style elements: theTT,I,B,BIG,SMALL,STRIKE,S, andU elements

<!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 is an informative description only.

TT: Renders as teletype or monospaced text.
I: Renders as italic text style.
B: Renders as bold text style.
BIG: Renders text in a "large" font.
SMALL: Renders text in a "small" font.
STRIKE andS:Deprecated. Render strike-through style text.
U:Deprecated. Renders underlined text.

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:

An example of rendering of various font styles

It is possible to achieve a much richer variety of font effects usingstyle sheets. 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 nestedfont style elements depends on the user agent.

15.2.2Font modifier elements:FONT andBASEFONT

FONT andBASEFONT aredeprecated.

See theTransitional DTDfor the formal definition.

Attribute definitions

size  =cdata[CN]
Deprecated.This attribute sets the size of the font. Possible values:
  • An integer between 1 and 7. This sets the font to some fixed size,whose rendering depends on the user agent. Not all user agents mayrender all seven sizes.
  • A relative increase in font size. The value "+1" means one sizelarger. The value "-3" means three sizes smaller. All sizes belong tothe scale of 1 to 7.
color =color[CI]
Deprecated. This attribute sets the text color.
face =cdata[CI]
Deprecated. This attribute defines a comma-separated list of font names the user agent should search for in order of preference.

Attributes defined elsewhere

TheFONT element changes the font size andcolor for text in its contents.

TheBASEFONT element sets the base fontsize (using thesize attribute). Font sizechanges achieved withFONT are relative tothe base font size set byBASEFONT. IfBASEFONT is not used, the default base font sizeis 3.

DEPRECATED EXAMPLE:
The following example will show the difference between the seven font sizes available 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:

Example of rendering of various font sizes

The following shows an example of the effect of relative font sizes usinga base font size of 3:

Example of rendering of various font sizes with a basefont

The base font size does not apply to headings, except where theseare modified using theFONT element with arelative font size change.

15.3Rules: theHRelement

<!ELEMENTHR - O EMPTY -- horizontal rule --><!ATTLIST HR%coreattrs;                          --id,class,style,title --%events;  >

Start tag:required, End tag:forbidden

Attribute definitions

align =left|center|right[CI]
Deprecated. This attribute specifies the horizontalalignment of the rule with respect to the surrounding context.Possible values:
  • left: the rule is rendered flush left.
  • center: the rule is centered.
  • right: the rule is rendered flush right.

The default isalign=center.

noshade[CI]
Deprecated.When set, this boolean attribute requests that the user agentrender the rule in a solid color rather than as the traditionaltwo-color "groove".
size =pixels[CI]
Deprecated.This attribute specifies the height of the rule. The default value forthis attribute depends on the user agent.
width =length[CI]
Deprecated.This attribute specifies the width of the rule. The default width is100%, i.e., the rule extends across the entire canvas.

Attributes defined elsewhere

TheHR element causes a horizontal ruleto be rendered by visual user agents.

The amount of vertical space inserted between a rule and the contentthat surrounds it depends on the user agent.

DEPRECATED EXAMPLE:
Thisexample centers the rules, sizing them to half the available width betweenthe margins. The top rule has the default thickness while the bottom twoare 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:

Example of rendering of various horizontal rules


previous  next  contents  elements  attributes  index

[8]ページ先頭

©2009-2025 Movatter.jp