The Hypertext Markup Language (short HTML) is a text based language which is usually used to build up the structure for a webpage.
HTML is NOT a programming language due to the fact, that you can’t implement processes or logic with HTML.
Sime exampe for a HTML file
<!doctype html> <html lang="de"> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>Title of the page</title> </head> <body> <p>This text will be displayed in the browser.</p> </body> </html>
What did we define here?
- It is a HTML 5 file
- Start of the html area and define the language of the page
- Start of the head area of the website
<meta name="viewport" content="width=device-width, initial-scale=1.0">
- The viewport of the webpage adjusts itself to the size of the clients device
- To learn more about what the Viewport is look HERE.
<title>Title of the page</title>
- This will be shown in the tab of the browser
- End of the head area
- Start of the body area
<p>This text will be displayed in the browser.</p>
- Display a “paragraph” with the given text inside it
- End of the body area
- End of the html area
What are HTML-tags?
Basically a webpage consists of HTML tags, which most of the time always have a start- and an end-tag:
Each “tag” has a special functionality. The most important HTML-tags can be looked up here: https://www.w3schools.com/tags/ref_byfunc.asp
But there are some exceptions which do not require an End-tag. Examples:
What are attributes?
Attributes are additional information that can be stores inside an HTML-tag:
- href in
- src in
- type in
These attributes are very dependent on each HTML-tag itself. Some of these attributes are required while others can be optional.
Universal attributes can be added to all HTML-tags. These are:
style are primarily used for styling, see Specificity – The priority in CSS for more information.
Of course there are more “globally” used attributes:
What is the DOM?
The Document Object Model (short DOM) is the tree structure which results from the given HTML-tags.
Here is a nice visualisation from W3Schools:
If you have an invalid DOM (e.g. a <div> is opened but never closed with a </div>) the browser usually tries to compensate or adjust accordingly but if you have to many errors in your DOM you will have very strange errors or problems on your webpage.
Thats why you should regularly check your DOM with the W3C Validator (https://validator.w3.org/) and fix at least the errors, if not also the warnings.