This site is designed for accessibility. Content is obtainable and functional to any browser or Internet device. This site's full visual experience is available in a graphical browser that supports web standards. Please consider upgrading your web browser.
Term | Meaning |
---|---|
@import |
A directive that instructs the web browser to load an external style sheet and use its styles in the rendering of the HTML document. The only real differencein using @import and LINK, is in the actual syntax of the command and its placement. As you can see, @import is found inside the STYLE container. It must be placed there, before the other CSS rules, or else it won't work at all. <STYLE TYPE="text/css"> Like LINK, there can be more than one @import statement in a document. Unlike LINK, however, the style sheets of every @import directive will always be loaded and used. So given the following, all three external style sheets will be loaded, and all of their style rules will be used in the display of this document: @import url(sheet2.css); The @import rule, like the link element, links an external style sheet to a document. This helps the Web author establish a consistent "look" across multiple HTML pages. Whereas the link element specifies the name of the style sheet to import using its href attribute, the @import rule specifies the style sheet definition inside a link element or a style element. In the scripting model, this means the owningElement property of the style sheet defined through the @import rule is either a style or a link object. The @import rule should occur at the start of a style sheet, before any declarations. Although Internet Explorer 4.0 and later allows @import rule statements to appear anywhere within the style sheet definition, the rules contained within the @import rule style sheet are applied to the document before any other rules defined for the containing style sheet. This rule order affects expected rendering. Rules in the style sheet override rules in the imported style sheet. This At-Rule syntax imports a style sheet fragment file to the current style sheet. It may be used in External and Embedded style sheets, but not with inline styles. Furthermore, multiple fragments can be imported in to a single style sheet, but all @import statements must occur before any style declaration Rule-Sets in the style sheet. An optional, case-insensitive argument can be specified after the URL of the fragment indicating one or more target media where the fragment should be applied (the default if no media is specified is "all".) Specifying media dependent styles via @import can be more efficient than @media At-Rules, because unneeded style fragments do not need to be downloaded or parsed in the @import case. Syntax |
@media |
The CSS1 specification was aimed primarily at describing
the visual rendering of documents. Times and needs are
changing, and the newer CSS2 specification recognized
that the use of different delivery platforms and
rendering devices was not only needed, but inevitable as
well. In allowing for other types of rendering devices,
CSS2 has created many properties and values which will
only be applicable on specific media types. CSS2 solves
this logistics problem by allowing style rules to be
selectively applied to differing rendering devices via
the @media At-Rule and the @import At-Rule.
Using this syntax, different CSS rules can be specified and applied from the same style sheet depending on whether the rendering device is the printed page, a computer screen, speech synthesizer, etc. An @media At-Rule specifies a comma separated list of case-insensitive media types, followed by a Rule Set embedded within matching curly braces ("{", "}".) If a browser supports a media type, it should support all style properties applicable to that media type. If no @media rule is specified for a Rule Set, it is applied to all media (default media = "all".) Syntax Examples An @media rule specifies the target media types
(separated by commas) of a set of rules (delimited by
curly braces). The @media construct allows style sheet
rules for various media in the same style sheet: @media
print { |
alternate stylesheet |
Alternate stylesheets are mutually exclusive. The user may select any one group and it will be applied but all the other alternates will be ignored. One of these alternates may be designated as the preferred style sheet group, which will be selected by default when the page is initially loaded. These style sheets can be selected by the visitor as alternatives to the preferred style sheet. This allows the visitor to personalize a site and choose his or her favorite scheme. They can also be used for accessibility (larger fonts etc). To specify an alternate style sheet, the rel attribute is set to alternate stylesheet and the style sheet is named with a title attribute. As with preferred sheets, these style sheets can also be grouped together by giving them identical title attributes. To make biggerfonts.css an alternate style sheet, the keyword alternate is added to the rel attribute. <link rel="alternate stylesheet" type="text/css" href="biggerfonts.css" title="biggerfonts" /> Note that these relationships only apply to external style sheets which are included using the link element. |
Device Indepnedence |
For Web content to be device independent, it should be possible for a user to obtain a functional presentation associated with its Web page identifier via any access mechanism. This is the fundamental principle for device independence from the user perspective. It does not say that the presentation will be the same on every device. But it does say that the user should be able to obtain a presentation and that the presentation obtained should be at least functional. The goal is that a functional presentation should be possible via any access mechanism. The method of presentation may vary according to the different access mechanisms, but the possibility of a functional presentation should always exist. In particular, it should be possible to provide a functional presentation even on a limited capability (i.e. low-cost) device - though it may be of reduced quality compared to that on more capable devices. |
Media Groupings |
|
Media Types |
In CSS1, all of the CSS properties were targeted to the then-dominant paged/visual rendering paradigm. Already, alternative web navigation devices are on the market, offering much more variety and capabilities than was common in the past. This crucial fact was recognized in the creation of CSS2, and the expectation is that the variety of rendering platforms for CSS will only grow as time goes by. CSS2 allows for the targeting of style rules to specific media types. This means you can explicitly request that one or more style rules will only apply when rendering to certain device types, such as a printer, an aural browser or a handheld device. Several methods exist to target one or more style rules to one or more media rendering device-types:
Ten Media Types:
|
Other style sheet languages |
|
persistent stylesheet |
A stylesheet that is always applied to the document. One example is the user agent's stylesheet: it's always applied, although you can override it with your own styles. In Mozilla milestones and builds, this is what the "Basic Page Style" entry in the "Use stylesheet" menu represents. It's largely up to the user agent to determine what is meant by a "preferred" stylesheet, but at this stage in the Web's development it's usually a persistent style. However, a user agent could eventually choose to do something else with preferred styles, such as ignore them. Or let the user switch them on and off as a group. Or even give their rules higher weight in the cascade than the rules from persistent stylesheets, regardless of the order in which they're specified. For now, I'd just treat preferred stylesheets as if they're persistent, unless we find that browsers do indeed treat them differently. These style sheets are always enabled (they are always on) and are combined with the active style sheet. They can be used for shared rules common to every style sheet. To make a style sheet persistent, the rel attribute is set to stylesheet and no title attribute is set. To make the style sheet paul.css persistent, the following link element would be included in the head: <link rel="stylesheet" type="text/css" href="persistent.css" /> |
Preferred stylesheet |
These style sheets are enabled by default (they are on when the page is loaded). They can then be disabled if the user selects an alternate style sheet. To make a style sheet preferred, the rel attribute is set to stylesheet and the style sheet is named with the title attribute. Several preferred style sheets can be grouped together by giving them identical title attributes. These grouped style sheets are then all enabled and disabled together. If more than one group of preferred style sheets are declared, the first group takes precedence. To make preferred.css preferred, a title attribute is added, giving the default style a name. <link rel="stylesheet" type="text/css" href="preferred.css" title="preferred" > |
Print-media styling |
If you're using Explorer, you can see the results of your print styles using the "Print preview." The other way to do it is to write a print stylesheet in screen media and then, when finished, switch the media value. For example, I might write a stylesheet that looked something like: <style type="text/css" media="screen"> ...and so on, making changes and previewing them in my browser. Once I had the stylesheet tweaked to my satisfaction, then I'd make one simple change: <style type="text/css" media="print"> In the meantime, while styling for print, I'd want to make sure I didn't have the actual screen-media styles interfering. So let's say that I had a screen-media stylesheet in the document. Before I started work on my print styles, I'd edit it to only apply to a medium like tty or aural-- something I knew my browser didn't support. Then, once I'd switched my print styles to actually have media-"print", I'd switch the tty value back to screen. Remember this, however-- the default value of media is all. So if you don't give a stylesheet a media value, it will be applied to your printouts as well as the screen display. |