|
To access the contents, click the chapter and section titles.
Platinum Edition Using HTML 4, XML, and Java 1.2
Using the <STYLE> TagAs you can see in Listing 9.1, embedded style information is placed between the <STYLE> and </STYLE> tags. When the W3C released HTML 3.2, it reserved the use of these tags specifically for the purpose of embedded style information. The HTML 4.0 recommendation now formalizes the use of the <STYLE> tag. The TYPE attribute tells a browser what type of style information setup is used and is most often set equal to text/css. Specifying other types allows for some flexibility in the implementation of other style information specification schemes in the future. This also makes it easier for browsers that do not support style sheets to ignore the style information between the two tags. Style information of the MIME type text/css is set up the same way that style information is set up in a linked style sheet file. The first entry on each line is the keyword from an HTML tag, followed by a list of characteristic/value pairs enclosed in curly braces. You can use any of the characteristics shown in Tables 9.1 or 9.2 when specifying your embedded style information.
Inline Style InformationYou can specify inline styles inside an HTML tag. The style information given applies to the document content up until the defining tags companion closing tag is encountered. Consider the following <TABLE> tag used on the American Boxer Clubs home page (see Figure 9.3): <TABLE BORDER=5 WIDTH=600 STYLE=float: none; padding-left: 10px; padding-right: 10px; padding-top: 5px; padding-bottom: 5px BORDERCOLOR=#800080 CELLSPACING=0 CELLPADDING=10 BORDERCOLORLIGHT=#800080 BORDERCOLORDARK=#800080 BGCOLOR=#EAEAEA> The STYLE attribute in the tag suppresses floating and pads the table with 10 pixels on the left and right sides and 5 pixels on the top and bottom. This gives the table that contains the pages content a little bit of breathing room on all sides.
Other Tags That Take the STYLE AttributeYou saw in the preceding example that the <P> tag can take the STYLE attribute to define an inline style. Many other tags can take the style attribute as well, including the following:
The <SPAN> TagFor those times when you want to apply a style to part of a document that is not nicely contained between two tags, you can use the <SPAN> and </SPAN> tags to set up the part of the document that is to have the style applied. You assign style characteristics to the area set up by the <SPAN> tag by using the STYLE attribute, as in the previous example with the <P> tag. As an example of how you might use the <SPAN> tag, consider the following HTML from the W3Cs style sheets home page: <P ID=p1><A HREF=#new><SPAN ID=s1>Whats new?</SPAN></A> <P ID=p2><A HREF=#what><SPAN ID=s2>What are style sheets?</SPAN></A> <P ID=p3><A HREF=#press><SPAN ID=s3>Press clippings</SPAN></A> <P ID=p5><A HREF=./CSS><SPAN ID=s5>CSS</SPAN></A> <P ID=p6><A HREF=#dsssl><SPAN ID=s6>DSSSL</SPAN></A> <P ID=p7><A HREF=XSL><SPAN ID=s7>XSL</SPAN></A>
|
Products | Contact Us | About Us | Privacy | Ad Info | Home
Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement. |