CSS (Cascading Style Sheets) style for rendering HTML element tags.

 
 

Look! Styles and colors

Manipulate Text
Colors,  Boxes
and more...


try it"


Examples

Try - Example

HTML uses style
This example demonstrates how to use the style information added to the <head> section of HTML format.

This example demonstrates how to use a style attribute do not underlined link.
How to make a style attribute is not underlined link.

A link to an external style sheet
This example demonstrates how to tag a link to an external style sheet.


How to Use CSS

CSS is used at the beginning of HTML 4, in order to better render HTML elements introduced.

CSS can be added to HTML in the following ways:

  • Inline style - using the "style" in the HTML element  attributes
  • Internal style sheet - HTML document head <head> region using <style>  element  to contain CSS
  • External reference - Use external CSS  file

The best way is through external CSS file references.

In HTML tutorial site we use inline CSS styles to introduce instance, which is to simplify the example, you can also make it easier for online editing code and run instances online.

You can learn more knowledge through CSS CSS tutorial site.


Inline style

When a particular style needs to be applied to the individual elements, you can use inline styles. The method of using the inline style is to use a style property associated Tags. Style attribute can contain any CSS property. The following example shows how to change the color of the paragraph and left margins.

<P style = " Color : Blue ; margin - left : 20px ; " > This is a paragraph. </ p> 

Learn more styles, please visit CSS tutorial.


HTML Style Example - Background Color

(Background-color) element defines a background color of the background color attributes:

Examples

<body style=""> <h2 style="">这是一个标题</h2> <p style="">这是一个段落。</p> </body>

try it"

Early BackColor property (background-color) using bgcolor attribute definition.

Try: Legacy HTML to set the background mode


HTML Style Example - font, font color, font size

We can use the font-family (font), color (color), and font-size (font size) attribute to define the font style:

Examples

<h1 style="font-family:verdana;">一个标题</h1> <p style="font-family:arial;color:red;font-size:20px;">一个段落。</p>

try it"

Now generally used font-family (fonts), Color (color), and font-size (font size) attribute to define text styles, instead of using <font> tag.


Examples of HTML styles - Text Alignment

Using text-align (text alignment) level attribute specifies the vertical alignment of the text:

Examples

<h1 style="text-align:center;">居中对齐的标题</h1> <p>这是一个段落。</p>

try it"

Text Alignment attribute replaces the old text-align tab <center>.

try it


Internal style sheet

When a single file requires special style, you can use the internal style sheet. You can <head> section through <style> tag defines internal style sheet:

<head>
<style type="text/css"> body {background-color:yellow;} p {color:blue;} </style> </head>


External style sheet

When the style needs to be applied to many pages when an external style sheet would be the ideal choice. Use an external style sheet, you can change a file to change the appearance of the entire site.

<head>
<link rel="stylesheet" type="text/css" href="mystyle.css"> </head>


HTML style tags

标签 描述
<style> 定义文本样式
<link> 定义资源引用地址


Deprecated tags and attributes

In HTML 4, the original definition of support HTML element style tags and attributes are deprecated. These labels will not support the new version of HTML tags.

Deprecated labels: <font>, <center>, <strike>

Deprecated attributes: color and bgcolor.