Lesson 3: HTML Principles
HTML principles
HTML has basic structuring rules and good practice principles like all other coding languages. A typical HTML page is laid out similar to in the following example. Example:
Explanation:
- In every html document that you create, you place DOCTYPE HTML in the first line of the HTML file. This is not a HTML element, but is a declaration that the following code is HTML version 5.
- Html- is known as the root element and all your HTML code. It is placed in between the opening and closing tags of the root element.
- Head- is the header element is where you place the content that you want to display in the header of the web page
- Body- contains all of the main content, for example text, images, and video.
Commenting
Similar to other coding languages, comments are left throughout HTML code to make it easier to understand and to explain the thought process of the author. In HTML, comments are formatted using the following syntax: Example:
<!-- This is a HTML comment -->
Everything inside the brackets is a comment and is not be displayed on the web page.
Nesting
Nesting in HTML is similar to nesting in Python and other coding languages. Nesting is when we place one HTML element in-between the tags of another element.
Example:
<u> I want <b> food. </b> </u>
Note how the bold tags are inside the underline tags. This is nesting.
Output: I want food.