How Does HTML Works?

HTML works by using a bunch of tags to show how a web page should be organized and what it should contain. When a web browser opens an HTML document, it reads these tags and shows the page's content accordingly.

Working in browser

  1. When a web browser finds an HTML file, it reads the code and makes a Document Object Model (DOM).
  2. The DOM looks like a tree and represents the HTML document, where each part of the tree matches an HTML element in the document.
  3. After that, the web browser uses the DOM to show the webpage. It begins at the top of the DOM tree and goes through the tree, showing each element along the way.
  4. How an element looks on the page depends on its type and characteristics.
  5. For example, a paragraph (<p>) shows as a block of text, and a heading (<h1>) shows as a big, bold font.
HTML DOM tree

Text-Based Language

  1. HTML is a text-based language, meaning it uses plain text, composed of characters and tags, to define the structure and content of a web page.
  2. These tags are enclosed in angle brackets < >.
  3. Initially, the developer uses a simple text editor on their computer, such as VS Code, Sublime, or Atom, to make their HTML document. Subsequently, the developer makes the HTML document with a sequence of HTML elements, using HTML tags for structuring and organizing content.
  4. For example, suppose the developer intends to create a website. In this case, the structure could include the use of the h1 tag for headings, h2 for subheadings, p tags for paragraphs, li for lists, and other elements such as nav, divs, and footer to effectively organize the content.

Markup Language:

  1. HTML is a markup language, not a programming language.
  2. It uses tags to mark or define different elements and their properties, rather than executing logic or operations like a programming language.