HTML Basics

HTML Basic

In html we need to know about tags and attributes. In this page we are going to see about the HTML tags and attributes.


What is HTML tag

HTML tags defines how the web browser must format and display the content.

Usually HTML tags contain start tag and end tag.


Syntax

<starttag>....</endtag>


Example

Try Yourself

But some HTML tags doesn't have end tag, they are

  • <img />
  • <br />
  • <hr />
  • <base />
  • <link />
  • <meta />

We will see about the tags deeply in the upcoming tutorials.


Difference between a HTML tag and HTML element

HTML tags denotes only the opening and closing entities.

HTML elements denotes the opening and closing entities as well as the contents present inside it.

Example

double click to execute the html file
HTML Tag
double click to execute the html file
HTML Element

What is HTML tag Attributes

HTML tag can have attributes.

An attribute cannot be repeated again in the same tag.

Attributes usually change the way a browser interpret the tags.

Attributes are written within the start tag.

Also we can create an user defined attributes. As per HTML standards user defined attributes start with data-*.

* - denotes the user defined text.


Example - Title Attribute

Try Yourself

In the above example title is the attribute name and This is the paragraph is the value.

When mouse is moved over the content (I am inside the paragraph tag), the title value (This is the paragraph) is displayed as tooltip.