w3schools    w3Schools
Search W3Schools :
   
HOME HTML CSS XML JAVASCRIPT ASP PHP SQL MORE...   References Examples Forum About
ADVERTISEMENTS

XML Certification
Download XML editor
Custom Programming
 
Table of contents
HTML Basic
HTML HOME
HTML Introduction
HTML Get Started
HTML Basic
HTML Headings
HTML Paragraphs
HTML Formatting
HTML Elements
HTML Attributes
HTML Styles
HTML Links
HTML Images
HTML Tables
HTML Lists
HTML Forms
HTML Colors
HTML Colornames
HTML Colorvalues

HTML Quick List

HTML Advanced
HTML Layout
HTML Frames
HTML Fonts
HTML 4.0 Why
HTML CSS
HTML Entities
HTML Head
HTML Meta
HTML URLs
HTML Scripts
HTML Attributes
HTML Events
HTML URL Encode
HTML Webserver
HTML Summary

Examples/Quiz
HTML Examples
HTML Quiz
HTML Exam

References
HTML Tag List
HTML Attributes
HTML Events
HTML Colornames
HTML Character Sets
HTML ASCII
HTML ISO-8859-1
HTML Symbols
HTML URL Encode
HTML Lang Codes
HTTP Messages

Selected Reading
Web Statistics
Web Glossary
Web Hosting
Web Quality

W3Schools Tutorials
W3Schools Forum

Helping W3Schools

 

HTML Styles

Previous Next

The style attribute is a new HTML attribute. It introduces CSS to HTML.


Look! Styles and colors

This text is in Verdana and red

This text is in Times and green

This text is 30 pixels high

Try it yourself


The HTML Style Attribute

The purpose of the style attribute is:

To provide a common way to style all HTML elements.

Styles was introduced with HTML 4, as the new and preferred way to style HTML elements. With HTML styles, styles can be added to HTML elements directly by using the style attribute, or indirectly by in separate style sheets (CSS files).

You can learn everything about styles and CSS in our CSS tutorial.

In our HTML tutorial we use the style attribute to introduce you to HTML styles.


HTML Style Examples

style="background-color:yellow"

style="font-size:10px"

style="font-family:Times"

style="text-align:center"


Deprecated Tags and Attributes

In HTML 4, some tags and attributes are defined as deprecated. Deprecated means that they will not be supported in future versions of HTML and XHTML.

The message is clear: Avoid the use of deprecated tags and attributes.

These tags and attributes should be avoided:

Tags Description
<center> Defines centered content
<font> and <basefont> Defines HTML fonts
<s> and <strikeout> Defines strikeout text
<u> Defines underlined text
   
Attributes  
align Defines the alignment of text
bgcolor Defines the background color
color Defines the text color

For all the above: Use styles instead.


Style Examples:


Background Color

<body style="background-color:yellow">

The style attribute defines a style for the <body> element.

Try it yourself: Background color

The new style attribute makes the "old" bgcolor attribute obsolete.

Try it yourself: Background the old way


Font Family, Color and Size

<p style="font-family:courier new; color:red; font-size:20px">

The style attribute defines a style for the <p> element.

Try it yourself: Font Example

The new style attribute makes the old <font> tag obsolete.

Try it yourself: Fonts the old way


Text Alignment

<h1 style="text-align:center">

The style attribute defines a style for the <h1> element.

Try it yourself: Centered heading

The new style attribute makes the old "align" attribute obsolete.

Try it yourself: Centered heading the old way


Previous Next


Make your web applications look like a million bucks

FusionCharts   

Most web applications today use boring methods to present data to their viewers using grids or simple HTML tables. FusionCharts induces "life" into the web applications by converting monotonous data into lively charts, gauges & maps.

FusionCharts works with all technologies like ASP, ASP.NET, PHP, ColdFusion, Ruby on Rails, JSP, HTML pages etc. and connects to any database to render animated & interactive charts. It takes less than 15 minutes and no expertise whatsoever to build your first chart and just a glance of it to captivate your audience. This fact is endorsed by our 12,000 customers and 150,000 users which include a majority of the Fortune 500 companies. And yeah, your applications could look like a million bucks by spending just $69.

So go ahead, download your copy of FusionCharts and start "wow-ing" your customers now!


 
WEB HOSTING
E Components
Ecommerce
Components
for ASP.NET
$15 Domain Name
Registration
Save $20 / year!
Buy UK Domain Names
Register Domain Names
Cheap Domain Names
Cheap Web Hosting
Best Web Hosting
PHP MySQL Hosting
Top 10 Web Hosting
UK Reseller Hosting
Web Hosting
FREE Web Hosting
WEB BUILDING
Website Templates
Flash Templates
Website Builder
Internet Business Opportunity
Custom Programming
FREE Trial or Demo
Web Content Manager
Forms,Web Alerts,RSS
Download XML editor
FREE Flash Website
FREE Web Templates
EDUCATION
US Web Design Schools
HTML Certification
JavaScript Certification
XML Certification
PHP Certification
ASP Certification
Home HOME or Top of Page Validate   Validate   W3C-WAI level A conformance icon Printer Friendly  Printer Friendly

W3Schools is for training only. We do not warrant the correctness of its content. The risk from using it lies entirely with the user.
While using this site, you agree to have read and accepted our terms of use and privacy policy.
Copyright 1999-2009 by Refsnes Data. All Rights Reserved.