HTML Basics


HTML (or HyperText Markup Language) is the language used for creating Web pages. The language itself is called a markup language because it uses markup tags to represent each element of a Web page. HTML is not a programming language like Java or a scripting language like JavaScript. It is designed to define WHAT needs to be displayed on a Web page.


HTML DOCTYPE

The first line of code in most every web page should be the <!DOCTYPE> declaration. This code is not an HTML tag but simply an instruction to tell the web browser about what version of HTML the page is written in. The latest version is HTML 5 and it is written as follows:

<!DOCTYPE html>


HTML Elements

Web pages are made up of elements. Each element is made up of a start (opening) tag and an end (closing) tag. An example of an HTML element would be the following:

<p>This is a paragraph</p>

Most elements come in the matching start/end pairs but there are a few elements that do not have an ending tag. These elements are called empty elements.


Block Elements

Block Elements are designed to occupy the whole width of the container it resides in. Thus they stretch out across the containing element that it resides. You cannot have two block elements appear side-by-side on a Web page.

Example block elements are:


Inline Elements

Inline Elements are designed to exist on the same line as other inline elements. They can exist side by side on a Web page. Web links and images are some examples of inline elements:

  1. Anchors - <a></a>
  2. Images - <img>
  3. Span - <span></span>

Image Examples:

Beyonce Computer Boy Gosling

Link Examples:

Iron Mountain Daily News | Facebook | Internet Movie Database

Empty Elements

Empty Elements are elements that do not have both an opening and closing tag. They only have an opening tag. These types of elements do not have content. Examples are as follows: