html files embedded in three ways CSS styles

CSS embedded in html document combination of the three ways

1. inline style

  • Style attribute specified in the tag css code
  • Such as:
	 <div style="color:red;">hello css</div>

2. Internal Style

  • In the head tag, the tag body content definition style tags, style css code label is
  • Such as:
	<style>
		div{
		color:blue;
		}
	</style>
	<div>hello css</div>

3. External Style

  • Steps for usage:
  1. Css defined resource file.
  2. In the head tag, tag link defined, the introduction of external resource files
  • The introduction of external resource files ways such as:
	//a.css文件:
	div{
		color:green;
	}
//在文档内部通过link标签引入,注意使用的是相对路径
<link rel="stylesheet" href="css/a.css">

<div>hello css</div>
<div>hello css</div>

4. Note:

  • 1,2,3 ways css effect of increasing the scope
  • 1 way is not common, common post-2,3
  • A third format of the second wording:
	<style>
		@import "css/a.css";
	</style>
Published 30 original articles · won praise 27 · views 6351

Guess you like

Origin blog.csdn.net/qq_43230007/article/details/104214888