Inline Styles 行内样式:

The use of an inline style is the most basic method used to stylize different elements in an HTML document. By using inline styles the programer can adjust a number of different style attributes such as the “font-size” and  “color” of a specific element.

行内样式的使用是用于设置HTML文档中不同元素样式的最基本方法。通过使用行内样式,编程人员可以调整许多不同的样式属性,例如特定元素的“字体大小”和“颜色”。

Style attributes can be applied to different HTML elements such as a paragraph tag <p> by adding a style attribute to the tag that will be stylized. 

通过向将被样式化的标签添加样式属性,样式属性可以应用于不同的HTML元素,例如段落标记<p>

Note 1: If the same style will be used by several different elements in an HTML document a programer can create a custom style using the style tag. By using the style tag a programmer can create an embedded style that can be used by multiple HTML elements in the document. This eliminates the need to retype the specific styles attributes multiple times.

注1:如果HTML文档中的几个不同元素使用相同的样式,程序员可以使用样式标签创建自定义样式。通过使用样式标签,程序员可以创建一个嵌入式样式,该样式可由文档中的多个HTML元素使用。这样就无需多次重新键入特定样式属性。

Note 2: If the same style will be used by multiple HTML documents a programmer can create an external style sheet and then apply the styles to multiple HTML documents. If the external style sheet is changed every HTML document that references that style sheet will also be updated automatically. This helps to insures that there is consistency between different HTML documents in a website.

注2:如果多个HTML文档使用相同的样式,程序员可以创建一个外部样式表,然后将这些样式应用于多个HTML文档。如果更改了外部样式表,则引用该样式表的每个HTML文档也将自动更新。这有助于确保网站中不同HTML文档之间的一致性。

Syntax 语法:

The style attribute can be added to a paragraph tag by adding style=“___”. When the when the paragraph tag is modified it will look like the following:

样式属性可以通过添加style=“___”到段落标签中。修改段落标签时,如下所示:

<p style:“___”> Content here… </p>

Example 例: 

Note: Using either inline or embedded styles is not as powerful as using an external style sheet; however it is important to learn how to create simple inline styles before attempting more complicated methods of stylizing your HTML documents.

注意:使用行内样式或嵌入式样式不如使用外部样式表强大;但是,在尝试更复杂的HTML文档样式化方法之前,了解如何创建简单的行内样式非常重要。

Continue to the next example: Style Tag