HTML – Basics

Share

The HTML Document forms the basis of what a web page is. All HTML documents must start with a document type declaration: <!DOCTYPE>. This tells the browser what version of HTML is expected within the document in order for the browser to render the page correctly.

The <!DOCTYPE> declaration must appear only once, at the top of the page before any HTML tags, and is not case sensitive.

The document type declaration below is what you should use as this is the declaration for HTML5, the modern HTML version.

<!DOCTYPE html>

The HTML document itself is a root element marked by a starting tag that begins the element with <html> and an ending tag that ends the element with </html>. There must only be one element in an HTML document.

The root element of the non-visible part of the HTML document is <head> and </head>. Meta-related elements are typically placed within the <head> element.

The visible part of the HTML document is the content that appears between <body> and </body>. It can include other elements, tags, and plain text.

Example of an HTML document.

<!DOCTYPE html>
<html>
   <head>
      <title>This is document title</title>
   </head>	
   <body>
      <h1>A Simple heading</h1>
      <p>Hello World paragraph!</p>
   </body>	
</html>

HTML Title

The HTML title is defined using the opening <title> and closing </title> tags. The content (typically plain text) is placed in between these two tags to complete the element. The content represents the title of the HTML document and appears in the Title bar or Tab of the HTML document. It is also the text that is used in search engine results. There must only be one element in an HTML document.

<title>This is the web page title</title>

HTML Headings

HTML headings are defined with the <h1> to <h6> tags.

<h1> tag defines the most important heading while <h6> tag defines the least important heading. An HTML document can have as many of these tags as needed.

<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>

HTML Paragraphs

HTML paragraphs are defined with the <p> tag. An HTML document can have zero or more <p> tags.

<p>This is a paragraph.</p>
<p>This is another paragraph.</p>

HTML Links

HTML links are defined with the <a> tag: The tag also requires the href attribute to specify the destination of the link as shown in the example below.

Note: Attributes are used to provide additional information about HTML elements. We will be looking at attributes later in this tutorial series.

<a href="https://brightwhiz.com">This is a link</a>

HTML Images

HTML images are defined with the <img> tag. This tag requires the src attributes to work as expected. Our example uses the following attributes:

  • src – The source file (path to the image, base64 representation of the image, vector code such as SVG, etc)
  • alt – The text to display if the src above connot retrieve the image
  • width – The width of the image
  • height – The display height of the image
<img src="brightwhiz.jpg" alt="brightwhiz.com" width="320" height="270">

Share