Tags, Attributes, and Elements in HTML


The basic structure of an HTML document includes tags, which surround content and apply meaning to it.

Change your document so that it looks like this.
<!DOCTYPE html>
    Place your content here

The use of tags is between two characters <and> so that the command can be recognized by the browser and tells the web browser how an object is displayed. In general, the use of tags in HTML is paired starting with <tag_opening> Contents of content </ tag_closing>, but there are also tags that are independent in writing such as <nama_tag /> tag called Void Element.

  place your content here 


Tags can also have attributes, which are extra bits of information. Attributes appear inside the opening tag and their values sit inside quotation marks. They look something like <tag attribute="value">Margarine</tag>. We will come across tags with attributes later.

<p align="justify">
  place your content here 

In the HTML code above, align = "jsutify" is an attribute. href is the name of the attribute, and justify is the value or value of the attribute.

Not all tags need attributes, but you will often see a tag with attributes, especially the id attributes and classes that are often used for web page manipulation using CSS and JavaScript.

HTML has many attributes, some of which are only suitable for certain tags. For example, the above "href" attribute is only used for <a> tags (and some other tags). An explanation of the purpose and understanding of attributes such as this href will be discussed in the following tutorials.


Tags tend not to do much more than mark the beginning and end of an element. Elements are the bits that make up web pages. You would say, for example, that everything that is in between (and includes) the <body> and </body> tags is the body element. As another example, whereas “<title>” and “</title>” are tags, “<title>Rumple Stiltskin</title>” is a title element.

<p>This is a <em> paragraph </em></p>

<p> This is a <em> paragraph </ em> </ p>
From the example above, <p> This is a <em> paragraph </ em> </ p> is a p element. In discussions or tutorials about HTML, it is not uncommon for the terms "tags" and "elements" to be exchanged.

No comments :