Referencing CSS styles in Web pages
- inline style
- Inline style sheet
- External style sheet
Inline mode
styleLabel
<!doctype html>>><metaCharSet="UTF8"><style> P{Color: Red;}</style> > <body> <p> This is a P tag! </p> </body>>
inline style
<!doctype html>>><metaCharSet="UTF8">><body><p style=" color ; " > This is a P tag! </p > </body>>
Outreach style Sheets-linked
linkLabel
Index.css
p { color: green;}
The link tag is then introduced in the HTML file:
<!doctype html>>><metaCharSet="UTF8"><linkRel="Stylesheet"Href="Index.css"> > <body> <p> This is a P tag! </p > </body>>
external style sheet [email protected] URL () mode import
Understand.
Index.css
url(other.css)
Attention:
@import url()Must be written at the beginning of the file.
The difference between a link and an import
1、<link/>标签属于XHTML,@import是属性css2.12、使用<link/>链接的css文件先加载到网页当中,再进行编译显示3、使用@import导入的css文件,客户端显示HTML结构,再把CSS文件加载到网页当中4、@import是属于CSS2.1特有的,对于不兼容CSS2.1的浏览器来说就是无效的
CSS Reference methods