Latest web development tutorials

HTML CSS

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

Look! Styles and colors

Manipulate Text
Colors, Boxes
and more ...


try it"


Examples

Try - Example

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

This example demonstrates how to use a style attribute do not underline links.
How to use the property to make a style not underlined links.

Link to an external stylesheet
This example demonstrates how Tags link to an external stylesheet.


How to Use CSS

In HTML 4, CSS is used, in order to better render HTML elements introduced.

CSS can be added to HTML in the following ways:

  • Inline style - use "style" attribute in HTML elements
  • Internal style sheets - at the head of an HTML document <head> area using the <style> element to contain CSS
  • External reference - Use external CSS file

The best way is through an external CSS file references.

In this site HTML tutorial we use inline CSS styles to introduce an instance, which is to simplify the example, but also makes it easier for you to edit the code online and online running instance.

You can site CSS tutorial, CSS tutorial to learn more CSS knowledge.


Inline style

When special style needs to be applied to individual elements, you can use inline styles. Use inline style is to use the style attribute in the relevant tag. Style attribute can contain any CSS property. The following example shows how to change the color of the paragraph and the left margin.

<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 background color attribute (background-color) define an element:

Examples

< body style = " background-color:yellow; " > < h2 style = " background-color:red; " > 这是一个标题 </ h2 > < p style = " background-color:green; " > 这是一个段落。 </ p > </ body >

try it"

Early background color attribute (background-color) is to use the bgcolor attribute definition.

Try: Older 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) to define the style of the font attributes:

Examples

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

try it"

Now commonly used font-family (font), color (color), and font-size (font size) attributes to define text styles, instead of using the <font> tag.


HTML Style Example - Text Alignment

Use 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-align text-align property to replace the old label <center>.

try it


Internal style sheet

When a single file requires special style, you can use an internal stylesheet. You can <head> section by <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, the external style sheet would be the ideal choice. Use 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 support custom HTML element style tags and attributes have been deprecated. These labels will not support the new version of HTML tags.

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

Deprecated attributes: color and bgcolor.