With HTML 4.0 all formatting can be moved out of the HTML document and into a separate style sheet.
HTML4.0中所有有关格式化HTML文档的内容都可以分离到一个样式表中
Examples
举例
Styles in HTML[在HTML中的例子]
This example demonstrates how to format an HTML document with style information added to the section.
这里演示了怎样在区域中添加样式信息去格式化一个HTML文档。
Link that is not underlined[无下划线的连接]
This example demonstrates how to make a link that is not underlined, using a style attribute.
演示怎样使用style属性让连接没有下划线
Link to an external style sheet[连接外部样式表]
This example demonstrates how to use the tag to link to an external style sheet.
演示怎样使用标签来连接到外部的样式表
How to Use Styles
怎样去使用样式
When a browser reads a style sheet, it will format the document according to it. There are three ways of inserting a style sheet:
浏览器会根据它所读取到的样式信息来格式化文档内容。一般有三种方式来插入样式表:
External Style Sheet
外部连接样式表
An external style sheet is ideal when the style is applied to many pages. With an external style sheet, you can change the look of an entire Web site by changing one file. Each page must link to the style sheet using the tag. The tag goes inside the head section.
当有很多页都需要一份类似的样式表时使用外部连接是个理想的选择。你可以改变一个文件而让所有用连接到此文件的网页改变外观。添加在头部区域内。
href="mystyle.css">
Internal Style Sheet
内置样式表
An internal style sheet should be used when a single document has a unique style. You define internal styles in the head section with the
Inline Styles
内联样式
An inline style should be used when a unique style is to be applied to a single occurrence of an element.
内联样式可以用在要给个别元素添加样式的时候。
To use inline styles you use the style attribute in the relevant tag. The style attribute can contain any CSS property. The example shows how to change the color and the left margin of a paragraph:
使用元素中的style属性,里面为CSS 内容。下面的例子将会演示怎样去改变段落的颜色以及左编辑:
This is a paragraph
To learn more about styles, visit our CSS tutorial.
想要学习更多有关样式的知识,请访问我们的CSS教程
Style Tags
样式标签
Tag
标签
Description
描述
Defines a style definition
样式定义
Defines a resource reference
定义引用资源
Defines a section in a document
定义文档区
Defines a section in a document
定义文档区
Deprecated. Use styles instead
不推荐。请用style替换
Deprecated. Use styles instead
不推荐。请用style替换
Deprecated. Use styles instead
不推荐。请用style替换

