HTML Basic

Simple Examples of HTML

HTML Documents

  • HTML documents must start with a document type declaration : <!DOCTYPE html>
  • HTML program must starts with <html> and ends with </html>
  • The content party or visible part of the HTML document is always written between <body> and </body>

Example of Heading Tag

<!DOCTYPE html>
<html>
<body>

   <h1>W3Professors My First Heading</h1>
   <p>Welcome to W3Professors My first paragraph.</p>

</body>
</html>
Execute Code

Tag used for Headings in HTML

  • We have <h1> to <h6> HTML tags which are used for headings
  • <h1> is known as the most important heading
  • <h6> is known as least important heading

Example

<h1>Heading 1  -  W3Professors</h1>
<h2>Heading 2  -  W3Professors</h2>
<h3>Heading 3  -  W3Professors</h3>
<h4>Heading 4  -  W3Professors</h4>
<h5>Heading 5  -  W3Professors</h5>
<h6>Heading 6  -  W3Professors</h6>
Execute Code

Use of <p> Tag (Paragraphs) in HTML

  • <p> tag is used in HTML for paragraphs

Example of <p> Tag

<p>Welcome to W3Professors. This is a paragraph.</p>
<p>Welcome to W3Professors. This is another paragraph.</p> 
Execute Code

Hyperlink in HTML <a> Tag (Anchor Tag)

  • <a> tag (anchor) is used for internal or external link in HTML
  • href attribute is specified for link's destination. It can be on same page or another page
  • Attributes means, Additional information about HTML elements or HTML tags

Example of <a> Tag

<a href="http://www.kanwertech.com">Kanwer Tech. This is a link</a>  
Click here to Run the Program

Image in HTML

  • <img> tag is used to define an images in HTML .
  • <img> have different attributes like source file (src), alternative text (alt), width, and height.

Example of <img> Tag

<img src="W3professors.png" alt="W3professors.com">   
Execute Code