CSS style external references

HTML There are three common ways defined CSS: embedded , external reference type , inline .
Below that the most common type of external references:

  1. Use stylesheet processing instruction statement
    written statement processing instructions about a style sheet at the beginning of the HTML document, as follows:
<?xml-stylesheet type="text/css" href="mystyle.css"?>
<html>
...
</html>

But only written using XML syntax of HTML documents only support the use of processing instructions, and most browsers only if the document is not saved as XHTML or XML format to take effect, and JavaScript can not handle such a CSS style sheet.

  1. Use @import instructions
    may be used between instruction @import style element introduced into an external CSS stylesheet files, as follows:
<head>
	<style>
		<!--下面两行代码的效果是相同的
			@import "mystyle.css";
			@import url("mystyle.css");
		-->
	</style>
</head>

Note: Any @import rules must appear before the rule where the style sheet.

  1. Use link element
    using the link element in the HTML code may be an external style sheet referenced, may be used to specify URL stylesheet href attribute is located, and specifies rel = "stylesheet" type = " text / css", the former indicates the referenced style sheet the latter is a reference to a CSS style sheet for example:
<head>
	<link href="mystyle" rel="stylesheet" type="text/css" />
</head>
  1. Using the HTTP message header linked to the style sheet
    may be used to link HTTP message header field of the same functions as a link to the external style sheet, and functional link field of the HTML link elements, have the same property, as follows:
link:<href="mystyle" rel="stylesheet" type="text/css" />

Equivalent to:

<link  href="mystyle" rel="stylesheet" type="text/css" />

HTTP header fields may be used a plurality of links link a plurality of external style sheet, and the link field of the HTTP header has a higher priority than the link element in the HTML document.

Guess you like

Origin blog.csdn.net/qq_44858021/article/details/90317779