What is HTML? HTML is an acronym for Hyper Text Markup Language and the standard markup language for Web pages maintained and developed by the World Wide Web Consortium (W3C). It is an element-based digital language that dictates the structure of web pages.
Every web page viewed on the World Wide Web uses some version of HTML code.
HTML uses elements to separate a webpage’s data into logical sections. It tells web browsers how a website’s webpages are structured.
In most cases, elements in an HTML document are defined by an opening and closing tag.
To create a paragraph, a tag is used, which requires an opening and closing tag. Like so:
<p>This is a paragraph example</p>
An HTML web document must start with a document type declaration, then beginning and closing html tags are inserted. Each web page consists of 3 basic sections, a head, title, and body.
The head includes metadata which is information that identifies the document. Metadata is the title (required), character set, styles, scripts, and other useful meta information. Besides the title, metadata doesn’t get displayed when a web page is visited.
The body defines the document’s body. This tag will contain all of the elements to be displayed, such as headings, paragraphs, images, hyperlinks, tables, lists, etc.
In the example below, we have created the basic markup of an HTML document.
HTML elements may also have attributes associated with them. Element attributes can provide additional information about them.
For example, an HTML element can have a unique id or class attribute. We can then use CSS to target those specific elements for styling.
HTML ID & CLASS Example:
There are also two main types of elements which are block-level and inline.
Block-level Elements:
Block-level elements take up the entire width of a web page and always start a new line in the document.
Block-level Element Example:
<h1>My Big Heading</h1>
<p>my first paragraph</p>
The <h1> and <p> tags are both block-level elements.
Inline Elements:
Inline elements are HTML elements that format the inner content of block-level elements, such as adding a link or making some text bold.
Inline Elements Example:
<p>My <strong>first</strong> paragraph</p>
<p>My second paragraph with a<a href="https://tarttweb.com/">Link!</a></p>
The <strong> and the <a> tags are both inline elements.
It is important to note that HTML is not considered a programming language as it cannot create any dynamic functionality. It is used to markup the document’s (web page) structure.
Use cases for HTML:
- Web development. HTML code is used by developers to markup a text file with the .html format designed with page elements such as text, hyperlinks, and media files. These files tell the web browser how to display the page on the World Wide Web.
- Internet Navigation. Hyperlinks allow users to easily navigate from one page to another by inserting links between related pages.
- Web documentation. Html makes it possible to organize and format documents.
The most common HTML file formats are .html, .htm, and .xhtml. However, there are other lesser-known formats such as:
.dhtml – a text file that contains dynamic HTML code. This file type is used for developing interactive Web pages that can change without being reloaded or opening another link.
.phtml – a text file that contains PHP code. The PHP code is parsed on the webserver to dynamically generate HTML code. “.php” is much more commonly used for web files containing PHP code.
.jhtml – a text file that contains Java code; may include Java functions that are processed on the server before the page is sent to the client’s Web browser.
.mhtml – Web page archive format saved from a .HTML file and encoded with .MIME encoding. Includes resources linked from the Web page, such as images, Flash animations, Java applets, audio files, etc. These file types can be opened and viewed without being online. Microsoft Word can save and open MHTML Web archives.
.rhtml – Web page containing Ruby code or scripts. It is processed on a Web server running Ruby on Rails before pages are sent to the Web browser.
.shtml – Web page written in HTML that contains server-side includes. It is processed by the Web server before being sent to the user’s browser. It can reference other files on the server, such as “header.shtml” or “_footer.shtml.”
.zhtml – Web page parsed by RabbitWeb, a Web server that integrates .C program code with special HTML tags. These files contain embedded “ZHTML” commands used to generate dynamic content for web pages.
For further learning, we recommend the HTML Tutorial at W3Schools.
Additional Reading: