HTML Attributes

HTML elements have attributes.
Attributes provide additional information about the elements that it is in.
Each attribute is within the start tag.
They are written in Name and Value pairs.
Example: name="Value"
HTML5 does not require quotes around the value but other versions require it so if you want your page to be read on other versions, use quotes.
Use double quotations. If the attribute value contains quotes, you can use either single or double quotes.
Example: <p title="Justin 'J-Hawk' Hawkes"> or <p title='Justin "J-Hawk" Hawkes'>

ATTRIBUTES:

lang
  • This is the "document language" and is placed within the <html> tag. 
  • Example: <html lang="en-US">
  • "en-US" states that your page is in english, that is spoken in the U.S. 
title
  • This is the "title" attribute 
  • The title must be placed within the start tag. Now, if you hover over the paragraph following the start tag a "tooltip" will appear and it will say whatever you put as the value. In my example I put "This Is Now A Tooltip". 
  • Example: <p title="This Is Now A Tooltip"> This is the paragraph following the tag</p>
href
  • href always goes with the HTML link tag (<a> and </a>)
  • The href attribute specifies what the URL of the page link goes to. 
  • If the href attribute is not present, the <a> tag is not a hyperlink. 
  • By typing in href= you are essentially saying "The URL of the link is (this)".
  • Example:
  • <a href="www.thechirp355.blogspot.com">Click This Link</a>
The following attributes go within an image tag:

src
  • Source File
alt
  • Alternative Text
  • This specifies what information will be displayed when the HTML element cannot be displayed. 
  • The value of the attribute can be read by "screen readers"
  • This means that someone "listening" to the webpage can "hear" the element. 
width
  • How long the photo is
height
  • How tall the photo is
border
  • specifies a boarder around the photo
Example: <img boarder="1" src="TheChirp.jpg" alt="TheChirp355.blogspot.com" width="102" height="132">

For an alphabetical list of HTML tags visit: http://www.w3schools.com/tags/default.asp

NOTE: If you want to view the HTML code of another webpage, right click, select "view page source" or "view source" and another page containing the HTML code will appear. 

Comments