HTML Elements And Attributes

When we want to start something we need to add to an HTML document in a form of a tag. Which starts with a <tagname> and ends with </tagname>.

HTML Elements And Attributes

So anything in between a tag is called an Element in HTML. 

There are two types of Elements in HTML,

Nested Elements

Those elements which contain other tags inside it are called Nested HTML elements.

For Example,

HTML Elements And Attributes

Empty Elements

Elements which do not have an end tag called empty elements. For example <hr /> or <br />.

The 2nd thing we need to understand about elements is attributes.

Attributes 

Attributes are used to add additional information for elements. Also, attributes are always based on the element type. It should be in the form of name=value. Some of the common attributes which are mostly used by every element are,

  1. Id
  2. Name
  3. Style
  4. Height 
  5. Width 

These are the most useful attributes for every element where id used to give a unique identity to an element so you can use the same ID for two elements in an HTML page. 

The 2nd very important attribute is the name that is used to post data from HTML. This is not unique so you can use the same name for two elements. But only data will be posted along with name when you post data from the HTML page. So this kind of issue you can face if you use the same name in two elements. 

Some other important things we can see,

HTML Comments

The 3rd very important tag in HTML is the comment tag which is not similar to HTML tags is comments. This is not usable for users because this is just to document your code and have a better reference for code added on-page. You can write a comment like this. 

<!-- Write your comments here →

This is only for use for developers or HTML coders.

Hope you understood about HTML element and attribute. Keep learning. 


Next Recommended Reading Script and Noscript Element in HTML