Friday, 22 August 2014

HTML Attributes

HTML Attributes are used to provide an additional info.  to the HTML elements.

HTML Attributes

•    HTML elements can have attributes
•    Attributes are always specified in the start/opening tag
•    Attributes come in name/value pairs like: name="value"
•    Attributes provide additional information to an element

Attribute Example

HTML links are defined with the <a> tag. The link address is specified in the HREF attribute:
<a href=""> link text</a>

Always Quote Attribute Values
Attribute values should always be enclosed in quotes.
Double style quotes are the most common, but single style quotes are also allowed.
     Tip: In some rare situations, when the attribute value itself contains quotes, it is necessary to use single quotes: name='Sumit "Sam" Joshi’

Tip: Use Lowercase Attributes

Attribute names and attribute values are case-insensitive.
World Wide Web Consortium (W3C) recommends lowercase attributes/attribute values in their HTML 4 recommendation.
Newer versions of (X)HTML will demand lowercase attributes.

Below is a list of some attributes that can be used on any HTML element:

Attribute                                           Description
class                       Specifies one or more class names for an element (refers class in a style sheet)
id                            Specifies a unique id for an element
style                        Specifies an inline CSS style for an element
title                          Specifies extra information about an element (displayed as a tool tip)

< Previous                                                                   Next >

No comments:

Post a Comment