1.2 跟css有關(guān)的標(biāo)記,指令1.2.1 link<link rel="stylesheet" type="text/css" href="sheet1.css" media="all" />link標(biāo)記的用意是允許將html與其他文檔相關(guān)聯(lián)。Css用link將css文檔與html文檔想關(guān)聯(lián)。Css文檔雖然不是html的一部分,但是被html使用,從外部style sheets引入它。Link在head元素內(nèi),但是不能放在任意head子元素的內(nèi)部,比如title。Css文檔的后綴名雖然不要求,但是有些瀏覽器不能識別非“.css”的文件。Link的屬性: rel:代表relation,設(shè)為stylesheet。 type:描述數(shù)據(jù)的類型,設(shè)為text/css,告訴瀏覽器style sheet是css格式的。以后還會有其他的style sheet,比如xsl。 href:style sheet的url。 Media:指定style sheet的使用范圍。下列大多數(shù)值還不被任何瀏覽器支持,常用的是all,print,screen。Opera支持projection。可以為media指定多個值,比如media="screen, projection"all Use in all presentational media.aural Use in speech synthesizers, screen readers, and other audio renderings of the document.braille Use when rendering the document with a Braille device.embossed Use when printing with a Braille printing device.handheld Use on handheld devices like personal digital assistants or web-enabled cell phones.print Use when printing the document for sighted users and also when displaying a "print preview" of the document.projection Use in a projection medium, such as a digital projector used to present a slideshow when delivering a speech.screen Use when presenting the document in a screen medium like a desktop computer monitor. All web browsers running on such systems are screen-medium user agents.tty Use when delivering the document in a fixed-pitch environment like teletype printers.tv Use when the document is being presented on a television. Title:利用title定義多個css文檔相互替換的關(guān)系。 比如存在如下定義: <link rel="stylesheet" type="text/css" href="sheet1.css" title="Default" /><link rel="alternate stylesheet" type="text/css" href="bigtext.css" title="Big Text" /><link rel="alternate stylesheet" type="text/css" href="zany.css" title="Crazy colors!" />那么能同時支持多個css定義的瀏覽器中會有如下表現(xiàn): 還可以通過將title設(shè)定為相同的value來分組: <link rel="stylesheet" type="text/css" href="sheet1.css" title="Default" media="screen" /> <link rel="stylesheet" type="text/css" href="print-sheet1.css" title="Default" media="print" />