Style Tag 样式标签

The style tag <style> is used for creating a specific style that will be used within your HTML document. The style tag is not visible to the person viewing a website and does not contain the actual content that will be stylized. Instead the style tag has a set of program codes that are used for styling the content in an HTML element that references the specific style.

样式标签用于创建将在HTML文档中使用的特定样式。查看网站的人看不到样式标签,并且不包含将被样式化的实际内容。相反,style标签有一组程序代码,用于为引用特定样式的HTML元素中的内容设置样式。

Note: A programmer can create more than one style; however each style will need to have its own unique name. To apply a style to an element the programmer needs to create a specific HTML element with open and close tags that have the same name as the style. 

注:程序员可以创建多个样式;但是,每种样式都需要有自己独特的名称。要将样式应用于元素,程序员需要创建一个特定的HTML元素,该元素具有与样式同名的打开和关闭标签。

Syntax 语法:

The style tag is written as <style>   </style> with the different styles inserted between the open and close tags.

样式标签写为<style>   </style>,在打开和关闭标签之间插入不同的样式。

Example 例: 

Note: This example shows how several different styles can be combined and applied to an HTML element in a document. Styles can be applied to multiple elements and large documents may have more than one style. The examples on the following pages will elaborate on the different style attributes shown in this example.

注意:此示例显示了如何将几种不同的样式组合并应用于文档中的HTML元素。样式可以应用于多个元素,大型文档可能有多个样式。以下页面上的示例将详细介绍本示例中显示的不同样式属性。

Continue to the next example: Style Attributers – Boarder