Cover | Table of Contents | Colophon
http://www.w3.org/MarkUp/). As you will see in more detail in Section 7.1, HTML 4.0 has a considerably larger vocabulary
than the previous release that is in common use, Version 3.2.
Surprisingly, this time around the standard is way ahead of the
browser makers. Many of the new features of HTML 4.0 are designed for
browsers that make the graphical user interface of a web page more
accessible to users who cannot see a monitor or use a keyboard. The
new tags and attributes readily acknowledge that a key component of
the name World Wide Web is World. Users of all different written and
spoken languages need equal access to the content of the Web. Thus,
HTML 4.0 includes support for the alphabets of most languages and
provides the ability to specify that a page be rendered from right to
left, rather than left to right, to accommodate languages that are
written that way.ID
or CLASS attribute). When a style sheet defines a
border, the style definition doesn't know (or care) whether the
border will be wrapped around a paragraph of text, an image, or an
arbitrary group of elements. All the style knows is that it specifies
a border of a particular thickness, color, and type for whatever
element or identifier is associated with the style. That's how
the separation of style from content works: the content is ignorant
of the style and the style is ignorant of the content.http://www.w3c.org/Style/). Chapter 10, provides a complete reference for all the
style attributes available in CSS1 and CSS2.P elements). Style rules influence the rendering
of elements, including their color, alignment, border, margins, and
padding between borders and the content. Style rules can also control
specialty items, such as whether an IMG
HTML element as a document object whose SRC
attribute could be changed on the fly to load an entirely different
image file into the space reserved by the
<IMG> tag. In DHTML parlance, this is known
as a
replaced element because it is rendered as an inline element (capable
of flowing in the middle of a text line), yet its content can be
replaced afterward. The most common application of this replacement
feature is the
mouse rollover, in which an image is
replaced by a highlighted version of that image whenever the user
positions the cursor atop the image. If you surround the
<IMG> tag with a link
(<A>) tag, you can use the link's
mouse event handlers to set the image
object's source file when the cursor rolls atop the image and
when it rolls away from the image:
<A HREF="someURL.html"
onMouseOver="document.images['logo'].src = 'images/logoHOT.jpg'"
onMouseOut="document.images['logo'].src = 'images/logoNORMAL.jpg'">
<IMG NAME="logo" SRC="images/logoNORMAL.jpg" HEIGHT=40 WIDTH=80>
</A>
IMG
element's HEIGHT and
WIDTH attributes when the page loaded. All other
images assigned to that object had to be the same size or risk being
scaled to fit. While rarely a problem for mouse rollovers, the lack
of size flexibility got in the way of more grandiose plans.
word-spacing
and white-space, are missing from the IE 4
implementation.<DIV> or <SPAN>:<IMG SRC="myFace.jpg" HEIGHT=60 WIDTH=40 STYLE="position:absolute; left:200; top:100">
<H1> header or the size of an image at any
time. The rendering engine instantaneously reflows the page to
accommodate the newly sized content. With each HTML element exposed
to scripting as an object, most properties can be changed on the fly.
The model even accommodates changing the HTML associated with an
element. For example, you can demote an USER_AGENT environment variable sent by the client
at connect-time and redirecting different HTML content to each
browser brand or version.H1 element in a document with
<FONT> tags to make all of those headings
the same color, you can use a one-line style definition in a style
sheet to assign a color to every instance of the
H1 element on the page. Of course, now that style
sheets make it easier to specify colors, margins, borders, and
unusual element alignments, you are probably adding more HTML
elements to your documents. So your documents may not be any smaller,
but they should be more aesthetically pleasing, or at least closer to
what you might design in a desktop publishing program.
<P>
tag, which has long been regarded as
a single tag that separates paragraphs with a wider line space than
the <BR> line break tag. HTML standards even
encourage this start-tag-only thinking by making some end tags
optional.
You can define an entire row of table cells without once specifying a
</TD> or </TR> tag:
the browser automatically closes a tag pair when it encounters a
logical start tag for, say, the next table cell or row.<BR> tag is one), an element
in a document should be treated as a container whose territory is
bounded by its start and end tags (even if the end tag is optional).
This container territory does not always translate to space on the
page, but rather applies to the structure of the HTML source code. To
see how "HTML-think" has changed, let's look at a
progression of simple HTML pages. Here's a page that might have
been excerpted from a tutorial for HTML Version 2:<P>
tag, which has long been regarded as
a single tag that separates paragraphs with a wider line space than
the <BR> line break tag. HTML standards even
encourage this start-tag-only thinking by making some end tags
optional.
You can define an entire row of table cells without once specifying a
</TD> or </TR> tag:
the browser automatically closes a tag pair when it encounters a
logical start tag for, say, the next table cell or row.<BR> tag is one), an element
in a document should be treated as a container whose territory is
bounded by its start and end tags (even if the end tag is optional).
This container territory does not always translate to space on the
page, but rather applies to the structure of the HTML source code. To
see how "HTML-think" has changed, let's look at a
progression of simple HTML pages. Here's a page that might have
been excerpted from a tutorial for HTML Version 2:<HTML> <HEAD> <TITLE>Welcome to HypeCo</TITLE> </HEAD> <BODY> <H1>Welcome to HypeCo's Home Page</H1> We're glad you're here. <P> You can find details of all of HypeCo's latest products and special offers. Our goal is to provide the highest quality products and the best customer service in the industry. <P> </BODY> </HTML>
H1, H2, etc.) is
a block-level element because it stands alone on a page (unless you
use DHTML positioning tricks to overlay other elements). Other common
block-level elements are P, UL,
OL, and LI.none, so that
they don't appear or occupy space on the page when you use
simple HTML tags without style sheets. But one of the purposes of
style sheets is to let you modify the values of those features to
create graphical borders, adjust margin spacing, and insert padding
between the content and border. In fact, those three
terms—border, margin,
and padding—account for about half the
style sheet attributes implemented in the Version 4 browsers.window object, which
represents the content area of a browser window or frame, is at the
top of the hierarchy. The window object contains
objects such as the history,
location, and document objects.
The document object contains objects such as
images and forms, and, among the most deeply nested objects, the
form object contains form elements, such as text
fields and radio buttons.value property) named
zipCode inside a form named
userInfo:window.document.userInfo.zipCode.value
STYLE
element to specify the syntax you are
using to define style sheets. The value of the
TYPE
attribute is in the form of a content-type declaration; it defines
the syntax used to assign style attributes. The formal CSS
recommendation by the W3C promotes a syntax of content type
text/css
. This TYPE attribute
is not required in today's leading browsers, but the CSS
recommendation does not believe that there should be a default type.
Therefore, I strongly recommend specifying the
TYPE attribute for all style sheets, in case some
other user agent (an HTML-empowered email reader, for example) should
implement a strict interpretation of the CSS standard in the future.
A STYLE element that relies on the CSS syntax
should look like the following:<STYLE TYPE="text/css"> ... </STYLE>
text/css type of CSS syntax. Navigator 4 also
includes an alternative syntax that follows the JavaScript object
reference format. This alternate type,
text/javascript, provides Java-Script equivalents
for most of the style attributes and structures provided by the
text/css syntax. The Navigator implementation also
includes the power to use JavaScript statements and constructions
inside <STYLE> tags to assist in defining
styles based on client- or user-specific settings (as demonstrated
later in this chapter). In other words, the implementation of style
sheets in Navigator 4 is largely CSS compatible, and style sheets can
be specified using either CSS or JavaScript syntax.text/javascript
with names such as JavaScript
Style Sheets (JSS or JSSS, depending on whom you talk to) or
JavaScript-Accessible Style Sheets. The official terminology changes
with the wind, but these earlier names are no longer part of the
Netscape marketing vocabulary. At last reading, the company referred
to this technology as "accessing style sheet properties from
JavaScript via the Document Object Model"—even though the
formal Document Object Model standard was far from complete at the
time.
|
Attribute Name—CSS Syntax (IE 4 and NN 4)
|
Attribute Name—JavaScript Syntax (NN 4)
| |
|---|---|---|
|
Box Properties
| ||
<STYLE>
tag pair or using
STYLE attributes of HTML tags. For ease of
maintenance and consistency throughout a document, I recommend using
a <STYLE> tag inside the
HEAD section of the document. But you can also
include STYLE attributes directly inside the tag
for almost any HTML element.<STYLE> and
</STYLE> tags. The collection of rules
within these tags is the classic instance of a CSS style sheet.
Because the elements to which you bind style declarations can appear
early in the body of the document (and may be bound to the
BODY element itself), you should use the
<STYLE> tag in the HEAD
section of your document. This guarantees that the style sheet is
loaded and in effect before any elements of the document are
rendered. Include the TYPE attribute in the
opening tag, as in:<STYLE TYPE="text/css">
style sheet rule(s) here
</STYLE>
H2 elements in the document but one
to be set to the color red; the exception must be blue.OL) group, you want
to assign different font sizes to each level.:first-letter
and
:first-line, respectively. It is up to the browser
to figure out where, for example, the first line ends (based on the
content and window width) and apply the style only to the content in
that line. If the browser is told to format the
:first-letter pseudo-element with a drop cap, the
browser must also take care of rendering the rest of the text in the
paragraph so that it wraps around the drop cap.<STYLE> tags to
create, for example, algorithmically derived values for style sheet
rules.
<HTML>
<HEAD>
<STYLE TYPE="text/css">
H1 {color:red; text-transform:capitalize}
P {color:blue}
</STYLE>
</HEAD>
<BODY>
<H1>Some heading</H1>
<P>Some paragraph text.</P>
</BODY>
</HTML><STYLE>
tag set, and from a STYLE attribute in a
tag—and there is the possibility that multiple style rules can
easily apply to the same element in a document (intentionally or
not). To deal with these issues, the CSS recommendation had to devise
a set of rules for resolving conflicts among overlapping rules. These
rules are intended primarily for the browser (and other user agent)
makers, but if you are designing complex style sheets or are seeing
unexpected results in a complex document, you need to be aware of how
the browser resolves these conflicts for you.BODY element; only
by way of inheritance does the default rule apply to some element
buried within the content. At the heavyweight end of the spectrum is
the style rule that is targeted specifically at a particular element.
This may be by way of an ID selector or the ultimate in specificity:
a STYLE attribute inside the tag. No rule can
override an embedded STYLE attribute.