How Attribute use in HTML and HTML5 ?

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

  • All HTML elements can have attributes
  • The HTML title attribute provides additional “tool-tip” information
  • The HTML href attribute provides address information for links
  • The HTML width and height attributes provide size information for images
  • The HTML alt attribute provides text for screen readers

Below is an alphabetical list of some attributes often used in HTML:

AttributeOptionsFunction
alignright, left, centerHorizontally aligns tags
eg. <div align:top></div>
valigntop, middle, bottomVertically aligns tags within an HTML element.
eg. <div valign:top></div>
bgcolornumeric, hexidecimal, RGB valuesPlaces a background color behind an element
eg. <body bgcolor:#ff0000;></body>
backgroundURLPlaces a background image behind an element
eg. <body background=”images/simplycode.jpg”></body>
idUser DefinedNames an element for use with Cascading Style Sheets.
eg. <div id=”header”></div>
classUser DefinedClassifies an element for use with Cascading Style Sheets.
eg. <div class=”header”></div>
widthNumeric ValueSpecifies the width of tables, images, or table cells.
eg. <div class=”header” width=”200px”></div>
heightNumeric ValueSpecifies the height of tables, images, or table cells.
eg. <div class=”header” height=”300px”></div>
titleUser Defined“Pop-up” title of the elements.
eg. <img src=”simplycode.jpg” titile=”HTML Attributes” />