Web Developer's Virtual Library: Encyclopedia of Web Design Tutorials, Articles and Discussions


WDVL Newsletter

Active Server Pages
JSP/Java Servlets
Microsoft SQL Server
Daily Backup
Dedicated Servers
Streaming Audio/Video
24-hour Support    

jobs.webdeveloper.com

Hiermenus


e-commerce
Partner With Us















Developer Channel
FlashKit.com
JavaScript.com
JavaScriptSource
Developer Jobs
ScriptSearch
StreamingMediaWorld
Web Developer's Journal
Web Developer's Virtual Library
WebDeveloper.com
Webreference
Web Hosts
XMLfiles.com

internet.com
IT
Developer
Internet News
Small Business
Personal Technology

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Application of the Different Styles

October 30, 2000

Looking now at the body of the document, you will see how we applied these four styles to various text elements:

<body>
<p class="stage">Enter certain Reapers, properly habited:<br />
they join with the Nymphs in a graceful dance; towards<br />
the end whereof Prospero starts suddenly, and speaks; after<br />
which, to a strange hollow, and confused<br />
noise, they heavily vanish</p>
<p><span class="speaker">Prospero.</span>
<span class="stage">(Aside)</span>
I had forgot that foul conspiracy<br />
Of the beast Caliban, and his confederates<br />
Against my life: the minute of their plot<br />
Is almost come. – <span class="stage">(To the Spirits)</span>
Well done! Avoid; no<br />
more!</p>
</body>
The first paragraph:
<p class="stage">Enter certain Reapers, ... they heavily vanish</p>
was assigned to the 'stage' class.

The second paragraph was not assigned to any class and so it defaults to the style of its parent element: the <body> element. This second paragraph includes three <span> elements. The first:

<span class="speaker">Prospero.</span>
was assigned to the 'speaker' class. The second:
<span class="stage">(Aside)</span>
as assigned to the 'stage' class. The third:
<span class="stage">(To the Spirits)</span>
as also assigned to the 'stage' class.

At the time that this book was written, only Microsoft Internet Explorer came close to supporting all of the CSS-1 and CSS-2 style sheet properties. Unfortunately, Netscape Navigator's support is spotty, at best. We will continue to user Microsoft Internet Explorer for the remaining examples in this chapter.

In Step 3, you send the document to the printer, which is a print media device. Since there is no style sheet associated with the print media type, your web browser uses its own default style sheet; the style sheet associated with the screen media type is ignored.

In Step 5, we add the print media type to the style element:

<style type="text/css" media="screen, print">
This means that the web browser will use the same style sheet that was used for displaying the document on the screen for the printing of the document on the page.

In Steps 6 and 7, we compare the printed version of the document with the displayed version of the document. Note that the text is properly italicized and aligned.

In Step 9, you add a second <style> element, setting its media attribute to print:

<style type="text/css" media="print">
<!--
body { font-size: 10pt }
span.speaker {font-size: 10pt; font-weight: bold}
span.stage {font-size: 10pt; font-style: italic}
p.stage {font-size: 10pt; font-style: italic; text-align: center}
-->
</style>
Having two different internal style sheets means that you can have two entirely different presentations for the screen and the printed page. In Step 9, you changed the font-size from 18-point to 10-point and used a bold font for printing rather than the colored background used on the screen.

While using media-dependent internal style sheets is very simple, there are some inefficiencies that become more apparent as you add support for more and more devices. Quite simply, the files will get large – one way around this problem is to use external style sheets.

Different Style Sheets for Different Devices
Beginning XHTML
Using the <link> Element


Up to => Home / Authoring / Languages / XML / BeginningXHTML




Jupiter Online Media: internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and Jupiter Online Media

Jupitermedia Corporate Info


Legal Notices, Licensing, & Permissions, Privacy Policy.

Web Hosting | Newsletters | Tech Jobs | Shopping | E-mail Offers