What is Tag, Element and Attribute in HTML5

Srinivas Vanamala
A free video tutorial from Srinivas Vanamala
Web Developer and Bootcamp Instructor
4.5 instructor rating • 8 courses • 159,066 students

Learn more from the full course

Learn HTML Basics

Learn to Write HTML. This course is useful for absolute beginners!

02:11:44 of on-demand video • Updated

  • You will learn HTML Basics from Scratch with Examples and Exercises.
  • How to Write Web Page using HTML.
  • Learn about the HTML Tags.
  • Quick Refresh on HTML Language.
English [Auto] Arun welcome to the lecture. Let's understand what is tied element an attribute. Let's understand what are these words called us tag element an attribute. Banks look something like this. You have a less than symbol then you have the name of the tank then you have greater than symbol then you have a closing tag which is called is less than forward slash and same name that you used it here okay and then you have some content inside it. So the starting tag is called a starting tag. You can see a starting tag right. And the ending tag is nothing but the ending to the one that is ending with the slash forward slash it's called us ending tag. You can also call the starting tag as an opening tag and obviously ending tag can be called us closing tag. So that's basically the definition of tag so when someone's a tag you should think of opening tag or closing tag or starting tag or an ending tag. Let's look at what is element. The whole thing from starting tag then the ending tag including the content is called this element. So when somebody says element they are referring to starting tag ending tag and the text as well. Okay. An example of an element could be a paragraph tag where it is denoted with B less then B and greater then then you have text inside it then you have less than four words not being read then. So everything in starting tag and the ending tag and the text is called us element. So how do you read this. You said this is a paragraph element and you can write text inside the stack. Okay you can switch or what between tag and an element so you can even see a starting tag and the ending tag and then you can even see it's an element. So that's basically the difference between tag and Element element is the completing tag is just the opening tag and the closing tag. Let's look at what is empty tag when you don't have good data from a starting and closing then you call it as an empty the empty tag is also called us self closing tag. You also have tags where you don't have to mention content if you see this example less then tag forward slash and Gretel then you don't have a starting that you only have the ending tag. And here you have starting tag and in a new tag but you don't have a data inside it these two examples are called as empty element which means you don't have a data in it if you want to add a new line that is denoted with B or element and it is in order like less than beard for what nationality then you don't mention any data in it and it is called as an empty element. Okay so that's how you basically read an empty element. Let's understand what is an attribute every element or every tag that you have can have additional properties attributes can also be called s properties properties means additional information about that element if you have a tag and you want to mention some additional properties of the tag you can give a name is equal to open codes value and the closing code okay you can mention the name and the value defined in the specification you cannot write whatever you want you have to follow the specification of achievement and use them okay. An example if you're writing a link or on hyperlink you have to mention where when someone clicks this text where that data has to go what is the you are location and what is the text that should be displayed on the browser so visit does is displayed and this will be linked when someone clicked the visitors do they have to go to this location. So in this whole element here today is nothing but an attribute to take one more my example I'm just using an example as a dog but dog is not a tag in HDMI when I'm just giving an example to understand the concept of attribute and if a dog element has something called this color attribute and color values Brown and the value of that dog is German Shepherd how your reading and understanding this dog element has a color attribute and color is the attribute of the dog element that's how you basically read it. Okay I'm trying to tell you how do you read this attribute. Okay so dog element has a color attribute and then it hit it off is basically an attribute of anger tag a it is also collars angered. And you can also see color is the attribute of dog element so okay it is how you lead an attribute so let's do a quick summary of what we have learned so this is the perfect example again name is not an it's general tag I'm just giving your definition of tag element and attribute so name here is basically called us opening tag the name here is called s closing tag an attribute is called us class and that class has some value and the name is basically seeing some person name and from starting tag to ending tag or opening tag to closing tag is Carla's element here you're trying to define a real time example you're trying to define a name a person name as John Smith and also you're adding some properties to it and you're seeing John Smith is in second class okay so if you define this you write something like this so you open and close with the opening and the closing tag you define some attributes to tell more about that person element is nothing but opening and closing. OK so this is the definition of tag element an attribute. Okay. So when we read and write about each team we will be using this language. I'll be saying tag I'll be saying element. I'll be using paragraph element header element. You know had one tag or you know I'll be saying the attribute of this each one tag could be there so don't get confused try to understand this language. There's a new language you're learning and try to use these words when you try to define which team. Okay so that's on his lecture of bag element an attribute and I'll see in the next one.