HTML elements explained: A beginner’s guide to understanding DTD and the structure of HTML documents

Welcome to the world of HTML, where structure meets style! If you’re just starting out on your web development journey, understanding the basic building blocks of HTML is crucial. This guide will walk you through the key concepts of Document Type Definitions (DTDs) and the structure of HTML documents. Get ready to dive into the fascinating world of web development!
Understanding DTD
First things first, let’s talk about DTDs. DTD stands for Document Type Definition and it’s like the blueprint for an HTML document. It defines the legal building blocks of an HTML document and describes the document structure with a set of rules. DTDs were used extensively in HTML 4.01 and earlier versions, but they have been largely replaced by XML Schema and Relax NG in more recent standards.
What does a DTD do?
A DTD tells the web browser how to parse an HTML document and what elements are allowed to appear within each element. For example, in the HTML 4.01 DTD, you can specify that a

element can contain text, images, or links, but not another

element.
Types of DTDs
There are three types of DTDs:
System DTD
: This type of DTD is stored in an external file and is specified using the
SYSTEM
keyword in the DOCTYPE declaration. It is useful for defining document types that are widely used across the web.
External DTD
: This type of DTD is also stored in an external file, but it is specified using the
PUBLIC
or
SYSTEM
keyword in the DOCTYPE declaration. It is commonly used for defining document types that are specific to a particular organization or project.
Internal DTD
: This type of DTD is defined within the HTML document itself and is specified using the
DOCTYPE
declaration. It is useful for small documents or for including additional declarations that are specific to the document.
The Structure of an HTML Document
Now that you have a basic understanding of DTDs, let’s move on to the structure of an HTML document. An HTML document consists of three main sections: the DOCTYPE declaration, the

element, and the document content.
The DOCTYPE Declaration
The DOCTYPE declaration is the first line of an HTML document and it specifies which DTD is being used for the document. For example:

This declaration tells the browser that the document is using the HTML 5 DTD.
The

Element
The

element is the root element of an HTML document and it encloses all the content of the document. The

element has two attributes:
lang
: This attribute specifies the primary language of the document.
manifest
: This attribute specifies the location of the web application’s cache manifest file.
Document Content
The document content is everything between the opening

tag and the closing

tag. It is divided into two main sections:
Head Section
: The head section contains metadata about the document, such as the title, character encoding, and links to CSS files. The head section is enclosed within the

element.
Body Section
: The body section contains the actual content of the document, such as text, images, links, and other elements. The body section is enclosed within the

element.
Elements in the Body Section
The body section of an HTML document can contain various elements, such as:
Text Elements
: Elements like

,

,

, etc., are used to define headings.
Block Elements
: Elements like

,

, and

are used to structure the content of the document.
Inline Elements
: Elements like

,

, and

are used to insert content within the text.
List Elements
: Elements like

    ,

      , and

    1. are used to create lists.
      Form Elements
      : Elements like

      ,

      , and