CSS cascade style learning [1]

Source: Internet
Author: User

1. Connect to an external style sheet
Add an external style sheet to an HTML webpage in the following format:
<Link ref = HREF = TYPE = MEDIA =>
<LINK> mark the head part of the document.
The REF attribute defines the link between the connection file and the HTML document. REL = StyleSheet specifies a fixed preferred style. A fixed style is always applied when the style sheet is activated. The web page producer cannot specify more than one preferred style.
The interaction style is indicated by REL = "Alternate StyleSheet. In this example, the third <LINK> tag defines an interactive style. You can choose to replace the preferred style table.
Note that browsers generally lack the ability to select interactive styles.
A single style can also be presented through multiple style sheets.
<Link rel = StyleSheet HREF = "basics.css" TITLE = "Contemporary">
<Link rel = StyleSheet HREF = "tables.css" TITLE = "Contemporary">
<Link rel = StyleSheet HREF = "forms.css" TITLE = "Contemporary">
In this example, three style sheets are combined into a "Contemporary" style, which is applied as a preferred style sheet. To combine multiple style sheets into a single style, you must use the same TITLE in each style sheet.
The optional TYPE attribute is used to specify the media TYPE -- text/css is a stacked style sheet -- allow the browser to ignore the style sheet types they do not support
The <LINK> tag also has an optional MEDIA attribute, which is used to specify the MEDIA or MEDIA accepted by the style sheet. Allowed values include
Screen (default), submitted to the computer screen;
Print, output to the printer;
Projection, submitted to the projector;
Aural, speaker;
Braille, submitted to the convex-text tactile sensing device;
Tty, Telex typewriter (using a fixed font );
TV, TV set;
All, all output devices.
An external style sheet is ideal when a style is applied to many web pages. Using external style sheets, web page makers can change the appearance of the entire website by changing only one file. Similarly, most browsers store external style sheets in the buffer, thus avoiding latency when displaying webpages if the style sheets are in the buffer.
2. Embed a STYLE sheet. a style sheet can be embedded in the document using the STYLE element:
A STYLE sheet can be embedded in the document using the STYLE element:
<Style type = "text/css" MEDIA = screen> <! -- BODY {background: url(foo.gif) red; color: black} p em {background: yellow; color: black }. note {margin-left: 5em; margin-right: 5em} --> </STYLE> The STYLE element is placed in the HEAD of the document. The required TYPE attribute is used to specify the media TYPE, and the LINK element is the same. Similarly, you can specify the TITLE and MEDIA attributes using STYLE.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.