HTML attributes are characteristics of an element that provide additional information or formatting. Some attributes are unique to the HTML elements that they are used with, and other attributes can be used on multiple HTML element. Attributes are placed in opening HTML tags in the following manner:
<p style="align: center;"> </p>
The style attribute is (or should be) the most commonly used attribute, also known as inline CSS. Although there are other attributes that can be used, some will not be supported by future versions of HTML, instead their functions will be a part of the CSS styling.
Below is a list of the attributes that are currently available. Keep in mind many are better off replaced with CSS.
The Attribute | The Options | What It Does |
accesskey | User Defined | Specifies Keyboard Shortcut to Access an Element |
align | right, left or center | Elements Align At Left, Right or Center (Horizontal) |
valign | top, middle or bottom | Elements Align At Top, Bottom or Middle (Vertical) |
bgcolor | numeric, hexadecimal | Places A Background Color Behind An Element |
background | URL | Places A Background Image Behind An Element |
class | Anything You Want | Cascading Style Sheet Class Of An Element |
color | numeric, hexadecimal | Defines the Text Color Of An Element |
contenteditable | true/false | Specifies If User Can Edit an Element's Content |
contextmenu | Menu id | Specifies an Element's Context Menu |
data-XXXX | User Defined | Custom Attributes |
dir | left, right | Specifies Text Direction |
draggable | true,false,auto | Specifies Whether User can Drag an Element |
dropzone | copy, move, link | Specifies Whether Dragged Data is Copied, Moved, or Linked |
height | A Number | Specifies Height Of Tables, Table Cells & Images |
hidden | hidden | Specifies Whether Element Should be Visible |
id | Anything You Want | Cascading Style Sheet Id Of An Element |
item | List of elements | Used to Group Elements |
itemprop | List of items | Used to Group Items |
lang | Specifies Language of Content | |
spellcheck | true, false | Specifies If Element Should Have Spelling/Grammer Checked |
style | CSS Style sheet | Specifies Inline Style for Element |
subject | User define id | Specifies Element's Corresponding Item |
tabindex | Tab number | Specifies Element's Tab Order |
title | User Defined | Element Titles |
translate | Specifies Whether or Not Content Should Be Translated | |
width | A Number | Specifies Width Of Tables, Table Cells & Images |
If you don't completely understand attributes yet, don't panic. They will become more clear as you test your newly-acquired skills.