HTML attributes
HTML Attributes
HTML tags can contain one
or moreattributes.
Attributes are added to a
tag to provide the browser
with more information
about how the tag should
appear or behave.
Attributes consist of
anameand avalueseparated
by an equals (=)sign.
Consider this example:
<body
style="background-
color:red">
Here
style="background-
color:red"
is the attribute.
Another ex:
<hr width="60%"/>
result in
Here
width="60%"
is the attribute added to
tag. Alignment
you can align text to left,
right, or center.
<h3 align="left">aligned
left</h3>
<h3
align="center">aligned
center</h3>
<h3 align="right">aligned
right</h3>
Result in:
aligned left
aligned center
aligned right
Many attributes are
available to HTML elements,
some are common across
most tags, others can only
be used on certain tags.
Some of the more common
attributes are:
Attribute
Description
Possible Values
width
Specifies the width of an
element (Numeric value)
height Specifies the height
of an element (Numeric
value)
align Specifies the
horizontal alignment of an
element left, center, or
right
class Used with Cascading
Style Sheets (CSS) (the
name of a class)
style Used with Cascading
Style Sheets (CSS) (style
information)
title Can be used to display
a "tooltip" for your
elements.