HTML Styles
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 blue
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 |
Description |
| 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
Reliable, Affordable, Feature-Rich Web Hosting!
Take the uncertainty out of Web hosting and let
GoDaddy.com put service, performance and value back in. No matter which
hosting type or plan you choose, your site receives 24/7
maintenance and protection in our world-class data center. Plus,
you get the expert, friendly service you deserve, from the
world's largest hostname provider.
With three plans to choose from and
prices starting at just $4.99 per month, GoDaddy.com is sure to have a plan that's
right-sized and right-priced just for you!
All plans feature FREE 24x7 setup, FREE 24x7 monitoring, best-
of-breed routers, firewalls and servers, 24x7 onsite physical security
and access to our exclusive Go Daddy Hosting Connection, THE place
to install over 30 FREE applications. Virtual Dedicated and Dedicated
Server plans also available.
Visit GoDaddy.com today.
Virtual Dedicated, Dedicated Server and unlimited plans also available.
Save 20% on 12 months or more of shared web hosting - Enter code w3s20off at checkout
|