• USA : +1 973 910 5725
  • INDIA: +91 905 291 3388
  • info@tekslate.com
  • Login

HTML Attributes

HTML Class Attribute

The class HTML attribute is used to associate an element with a style sheet, and specifies the class of element, you learn more about the use of the class attribute when you will learn cascading Style sheet(CSS). The value of the attribute may also be a space-separated list of class names. For example.

class=”className1   classname2   classname3”

HTML Style Attribute

The style HTML attribute  allows you to specify CSS rules within the element. For example

<p style=”font-family:arial; color:#FF0000;”>Some text… </p>

Generic Attributes

Here’s table of some other attributes that are readily usable with many of HTML’s tags.

AttributeOptionsFunction
alignright,left,centerHorizontally aligns tags
valigntop,middle,bottomVertically aligns tags within an HTMl element.
bgcolornumeric, hexadecimal,RGB valuesPlaces a background color behind an element
backgroundURLPlaces an background image behind an element
IDUser DefinedNames an element for use with cascading style sheets
ClassUser definedclassifies an element for use with cascading style sheets
WidthNumeric valueSpecifies the width of tables, images, or table cells
heightNumeric valueSpecifies the height of tables, images,or table  cells
TitleUser Defined“Pop-Up” title for your element.

We will see related examples as we will proceed to study other HTML tags.

World wide web Consortium(w3c) recommends lowercase in HTML 4, And demands lowercase tags in XHTML

Attributes

An attribute is used to define the characteristics of an element and is placed inside the element’s opening tag. All attributes are made up of two parts: a name and a value.

The value of the attribute should be put in double quotation marks, and is separated from the name by the equals sign

Many HTML tags have a unique set of their own attributes. Right now we want to focus on a set of generic attributes.

Core Attributes

The four core attributes that can be used on the majority of HTML elements(although not all) are:

  • id
  • title
  • class
  • style

HTML id Attribute

The id HTML attribute can be used to uniquely identify any element within a page(or style sheet). There are two primary reasons that you might want to use an id attribute on an element:

If an element carries an id attribute as a unique identifier it is possible to identify just that element and its content.

If you have two elements of the same name within a webpage(or style sheet), you can use the id attribute to distinguish between elements that have the same name.

For now, the id attribute could be used to distinguish between two paragraph elements, like so:

<p id=”html”> This para explains what is HTML</p>

<p id=”css”>This para explains what is casecading style sheet<\p>

Note that there are some special rules for the value of the id attribute, it must :

Begin with a letter (A.Z or a.z) and can then be followed by any number of letters, digits(0,9), hyphens, underscores, colons, and periods.

Remain unique within that document; no two attributes may have the same value within that HTML document.

HTML Title Attribute

The title HTML attribute gives a suggested title for the element. The behavior of this attribute will depend upon the element that carries it, although it is often displayed as a tooltip or while the element is loading. 

Use Lowercase Attributes

Attribute names and attribute values are case-insensitive.

However, the World Wide Web Consortium(w3c) recommends lowercase attributes/attribute values in their HTML 4 recommendation.

Newer versions of (X) HTML will demand lowercase attributes.

Summary
Review Date
Reviewed Item
HTML Attributes
Author Rating
5

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on HTML Attributes"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Site Disclaimer, Copyright © 2016 - All Rights Reserved.

    Support


    Please leave a message and we'll get back to you soon.

    I agree to be contacted via e-mail.