Commonly used HTML tags

Commonly used HTML tags

·

3 min read

<!DOCTYPE html>

Actually, DOCTYPE is not an HTML tag but it is important to know about this because this tells the browser which version of HTML you are using. like any other programing language, HTML has also evolved. so in previous versions of HTML, we didn't have a Canvas tag. you can see the versions and their supported tags.

html-versions.PNG

html

All the Html we write in a .html file goes into the Html tag except <!DOCTYPE html>. as you can in the picture below.

html-tag.PNG

head

HEAD tag as the name suggests is the header that contains information that is not displayed on the webpage but is useful for machines to understand what this page is all about. Elements that can be used inside the head tag are:-

  • title
  • base
  • link
  • style
  • meta
  • script
  • NoScript
  • template

You can see how the head tag looks like

head tag.PNG

body

All the visible parts of the webpage come under the body tag. as you are reading this article this information is placed somewhere in the body tag.

body-tag.PNG

title

Inside the title tag, we write the title of the document. see below how we can write a title tag.

title tag.PNG

h1

If you want to add a heading to your document you can write an h1 tag which renders bigger and bolder font by default. we have 5 more tags similar to h1. these are h2, h3, h4, h5, and h6. all these tags render bold and bigger text but with different sizes, h1 is the biggest h2 is smaller than h1, and so on.

code :

h1-h6-tags.PNG

Webpage preview :

h1-h6-tags-preview.PNG

p

the p tag is generally used when you write something in paragraphs. in the code below I wrote 2 paragraphs.

code :

p-tag.PNG

Webpage preview :

p-tag-preview.PNG

br

the br tag is used when you want to start something from the next line.

before br tag code :

br-before-code.PNG

before br tag webpage preview :

br-before-preview.PNG

after br tag code :

br-after-code.PNG

after br tag webpage preview :

br-after-preview.PNG

hr

the hr tag Creates a horizontal line on the page. I have created 5 hr tags you can see the rendered output below.

code :

hr-tag.PNG

webpage preview :

hr-tag-preview.PNG

<!-- . . . -- >

All code that is starting from tag will not render to the webpage

code:

comment-tag.PNG

a

a tag is used to navigate from one page to another page or on the same page from one section to another section in the code below I have created a tag that will navigate you to google.com. if you want to navigate to another website then change google.com to that page you want to navigate.

code:

a-tag.PNG

webpage preview : whenever you click on google it will redirect you to google.com

a-tag-preview.PNG

img

img tag is used to display images on the webpage. in img tag, there are 2 attributes that you should always provide src="path" and alt="information about the image"

code:

img-tag-code.PNG

webpage preview :

img-tag-preview.PNG