" tag; 3. External style sheets place CSS styles in ".css" files outside the web document."/> " tag; 3. External style sheets place CSS styles in ".css" files outside the web document.">
Home >Web Front-end >Front-end Q&A >What are the types of style sheet css?
There are three types of style sheet css: 1. Inline style sheet, which puts the CSS style directly in the tag within the line of code through the style attribute; 2. internal style sheet, which puts the CSS style in "
The operating environment of this tutorial: Windows 7 system, CSS3 version, Dell G3 computer.
One or more CSS styles can form a style sheet. Style sheets include inline style sheets, internal style sheets and external style sheets. There is no essential difference between them. They are all composed of one or more styles.
1. Inline style sheet
Inline style is to put the CSS style directly in the tag within the line of code, usually in the tag Among the style attributes, since the inline style is directly inserted into the tag, it is the most direct way, and it is also the most inconvenient style to modify.
Example:
<p style="background-color: #999900">行内元素,控制段落-1</p> <h2 style="background-color: #FF6633">行内元素,h2 标题元素</h2> <p style="background-color: #999900">行内元素,控制段落-2</p> <strong style="font-size:30px;">行内元素,strong 比 em 效果要强</strong> <div style="background-color:#66CC99; color:#993300; height:30px; line-height:30px;">行内元素,div 块级元素</div> <em style="font-size:2em;">行内元素,em 强调</em>
2. Internal style sheet
The internal style sheet is included in
If a web document contains multiple
Example:
<style type="text/css"> p{ text-align: left; /*文本左对齐*/ font-size: 18px; /*字体大小 18 像素*/ line-height: 25px; /*行高 25 像素*/ text-indent: 2em; /*首行缩进2个文字大小空间*/ width: 500px; /*段落宽度 500 像素*/ margin: 0 auto; /*浏览器下居中*/ margin-bottom: 20px; /*段落下边距 20 像素*/ } </style>
3. External style sheet
If the CSS style is placed in a file outside the web page document , is called an external style sheet, and a CSS style sheet document represents an external style sheet.
In fact, the external style sheet is a text file with the extension .css. When you copy the CSS style code into a text file and save it as a .css file, it is an external style sheet.
As shown below is an external style sheet
The character encoding of the CSS source code can be defined at the top of the external style sheet file. For example, the following code defines the character encoding of the style sheet file as Simplified Chinese.
@charset "gb2312";
If you do not set the character encoding of the CSS file, you can keep the default settings, and the browser will parse the CSS code according to the character encoding of the HTML file.
(Learning video sharing: css video tutorial)
The above is the detailed content of What are the types of style sheet css?. For more information, please follow other related articles on the PHP Chinese website!