What are HTML Attributes
Attributes: what are they and how to work with them in HTML.
In this video we take a step back from creating real HTML files to talk about what attributes are and mainly what are there relationship to regular tags. Tags can have attributes. The attributes help define extra information that isn't part of the default settings of a tag. In the example of images the image tag is called the IMG tag. How could we let the image know what image it should load, how big should it be and so forth. The way we solve this problem is by setting attributes. Don't worry in this video we explain how it works and in the following video we will see it in action.
Video Transcript
00:00Welcome back. We're going to learn now something that is really cool,
00:04We're going to take now a step back from whet we've been doing so far and talk
00:08about properties and attributes in general
00:12Before we go into learning any other attribute, any other component
00:16we have to learn something new
00:20I'm going to open up a new file so we could look at things more easily
00:27So far we made tags, we said that when we create a tag we open it and we close it
00:32We said we could also create a tag where we automatically close it
00:36it's a self bound tag, we also learnt that tags have to be nested
00:40so if I open up a tag and close a tag and I want to put another tag inside then I have to nest it
00:46and I would never create a tag2 and open it inside of one tag but close it outside of it, right ?
00:53we said that is completely illegal,
00:55The next thing we want to learn is that some tags, have properties
00:59Until now we created things that just didn't have any properties , for example:
01:03if we wanted to load an image - the image has a tag that is called 'img'
01:08but we have to tell it where the image is,
01:13now how do we tell it where the image is ? We have to give it a property
01:16now the way to put property inside of HTML is by putting a space after the image, after the tag
01:22so if it's going to be a 'tagNAme attributeName = 'attributeValue'
01:33and we could do that a couple of times if a tag has some extra information then we would create a tag name
01:38attribute name and attribute value, now don't worry, It sounds a little bit weird
01:42but basically if you have to give it some sort of annalogy you could say for example,
01:47if you had a car and you want to say that that car is blue,
01:54you wouldn't create a car and then inside of that car create a color tag
02:04because the color doesn't belong to the car,
02:06the color is just a thing that the car is, the car is blue
02:09but it doesn't make sense to put this as nested element.
02:14As a nested element makes sense to say 'people' inside maybe
02:25and let's say there is 4 people inside because you're nested inside really, these are people inside of the car
02:30this is exactly the same thing as a paragraph, so inside of my paragraph,
02:36I have things that are bold, some things are bold some things are not, but it's stuff that is inside of my paragraph
02:44In a case of my car, would it be right to say that inside of my car I have blue ?
02:50No. Blue is really a part of the attributes of the car itself
02:55and because it's a part of the attributes of the car itelf I would put the space and say: color equals blue
03:01and this would be more logical if we're treating this attributes as if they were real things
03:05and that's exactly how HTML works as well,
03:08-Does it make sense ? -uhm.
03:10-Excellent. So now, in our next video we're going to meet our first attribute when we're going to meet our new tag
03:16which is going to be images
03:18Join us in our next video, we're going to learn about images
