Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
Miguel Nunez
3,266 PointsWhat is a HTML Attribute?
I'm referring to HTML.
Miguel Nunez
3,266 PointsSo is the Attribute like a desirable extension option that you want for the tag to do more in your vision? like for example you can press a video play button to play a video vs you can have a video play automatically when the webpage loads up.
4 Answers
William Li
Courses Plus Student 26,868 PointsYou may think of attribute as an extra piece of information attached to a HTML tag.
<div class="container"></div>
class here is an HTML attribute; and there're a lot more. Different HTML tags have different attribute options you may apply to.
The whole purpose of attribute is to allow developer to better customize each HTML tag element, and also to differentiate one tag from another so that they can be easily styled with CSS selector. Because, let's face it, it's not uncommon for one HTML source to contain hundreds of div tags, without attribute, we can't tell one apart from another; with attribute, we can group them into class, or single one out by assigning id.
Also check out this W3school page on HTML attribute http://www.w3schools.com/html/html_attributes.asp
Miguel Nunez
3,266 PointsOoo so customizable options for a tag? So for example lets just say you have a video play button to play a video vs you can have a video play automatically when the webpage loads up. Is that what you mean just adding desirable features for your html tags right?
Yaroslav Kleshchev
8,744 PointsAn attribute is an extra info that can be added to en element. This allows developers to easily target and customize html elements. languages like JavaScript and css take advantage of attributes.
Floyd Orr
11,723 Points<html>
Think of it like this. It's something that tells you more about an element, and it many times has an "= "with a value attached to it. Look at this code for a image tag:
<img src="MDN.jpg">
img =element (a image tag, this tells you what it is)
src = attribute (source, telling you it has a location)
MDN.jpg = value (the actual location of the image )
the element is the thing, the src is telling you more about it and the address is the value of the src. I hope that helps and don't forget to click best answer for the answer that helps you the most.
</html>
Jonathan Grieve
Treehouse Moderator 91,254 PointsMost elements have the same attribute. These are called global attributes.
Examples of these include
accesskey,
class,
contenteditable,
contextmenu,
data ,
dir,
draggable,
dropzone,
hidden,
id,
lang,
spellcheck,
style,
tabindex,
title,
translate,
But there are some attribuetes that are unique to an element. Have a look at this link for a list of attributes and what they can do. http://www.tutorialspoint.com/html5/html5_attributes.htm :-)
Floyd Orr
11,723 PointsFloyd Orr
11,723 PointsThink of it like this. It's something that tells you more about an element, and it many times has an "= "with a value attached to it. Look at this code for a image tag: <img src="mdn.jpg" width="104" height="142">
img =element (a image tag, this tells you what it is) src = attribute (source, telling you it has a location) w3schools.jpg = value (the actual location of the image )
the element is the thing, the src is telling you more about it and the address is the value of the src. I hope that helps and don't forget to click best answer for the answer that helps you the most.