XHTML - SPLessons
SPLessons 5 Steps, 3 Clicks
5 Steps - 3 Clicks

XHTML Attributes

XHTML Attributes

shape Introduction

This chapter demonstrates about the XHTML Attributes which gives some additional information about the elements. Following are the concepts covered.
  • About Attributes
  • Types of Attributes

About Attributes

shape Description

XHtml Attributes are defined as thename/value pairs Eg: href=”URL” ((href= name) and(URL=value)). XHtml elements have several types of attributes to display the various types of information. The attributes should be added in starting tags only, the below figure explains about the attributes. The code below demonstrates the Attributes of the xhtml elements. [html] <!DOCTYPE html> <html> <body> <a href="http://www.splessons.com/">This is a link</a> </body> </html> [/html] Result By running the above code in a preferred browser user can get the following output as shown in below image. Rules and Values XHTML Attribute possess some rules. Following are some of the rules to be followed while using attributes. XHTML elements have some attributes, these attributes defines some more information about elements.User have to give attributes always in start tag, and it will come as pair i.e. Syntax [html] <tagname attributename="Value"></tagname> [/html] XHTML allows to write multiple for a single tag as shown below. [html] <a href="http://www.splessons.com/" class="myclassname" ></a> [/html] The code below demonstrates the XHTML attributes as shown below. [html] <html> <a href="http://www.splessons.com/">Click Here to go SPLessons Home Page</a> <!-- Anchor tag used in navigation.--> <br /> <br /> <img src="http://www.splessons.com/wp-content/uploads/2013/11/SPLessonsSmall.png" alt="Logo" /> <!-- img tag used display images in web page.--> </html> [/html] Result By running the above code in a preferred browser user can get the following output as shown in below image.

Types of Attributes

shape Description

There are many XHTML attributes these are standardly associated with the XHTMl tags in which some attributes are listed below. Core Attributes Core attributes are not valid in html, base, meta, head, param, style, title and script elements. in which some attributes are listed below.
Attribute Value Description
Class class_rule Which is element of the class
style style_Definition Which is an inline style Difinition.
Id id_name Which is an unique id for the element.
Title tooltip_text Which displays a text at mouse tip.
Language Attribute The lang attribute which indicates enclosed content language. In order to identify The language ISO standard language abbreviations is used, like fr is used to recognize French and en is used recognize English, and so on.
.
Attribute Value Description
lang language_code Which sets the language code
dir ltr_rtl sets the text direction

Summary

shape Key Points

  • Attributes should be always given in the starting tag only.
  • Attributes are utilized to give the extra information of the elements.
  • Attributes can be written in lowercase or upper case.