Content
Format of an HTML page
Its essential principle is the use of labels. The labels are reserved words of the language, enclosed in < >
Types of labels
There are three types of tags:
- Paired
when a start and end tag appears, the blocks contained between start and close are elements, which in turn may contain other elements - No match
when the label represents the insertion of an element, these tags end with a forward slash - With final optional
are the labels paired in the which it is not mandatory to use the end tag
The labels can include attributes modifying its behavior, specifying some unique characteristic of the element or including additional information
The attributes are specified as pairs attribute='value', separated by spaces within the home label
Values are not required to be enclosed in quotation marks, but it is recommended
Single or double quotation marks can be used interchangeably, as long as they match their opening and closing
The example has used the id attribute, which is generic for any tag and which will be useful to us when using CSS and Javascript, because it allows us to uniquely distinguish the element to which that particular tag belongs
There are more generic attributes, such as class, title or style, all very useful when we want to format or improve accessibility to our elements
When we introduce a label that does not exist, it will be ignored, we must pay attention to this issue because it makes it difficult to detect errors
The labels can be typed in uppercase or in lowercase
Line breaks and extra white space are not considered. The latter allows you to indent your code to make it more readable
Comments within the HTML
Sometimes it is very useful to write comments in the HTML document about the code we write, they can serve to remind us later what was done, and that we do not want it to be seen on screen
This is achieved by enclosing such comments between these two symbols:
Comments can be used anywhere in the HTML document, but will not be displayed
Special characters
There are certain characters that a browser is not able to recognize in spite of using the correct encoding
Let's imagine that we want to write the text x > y within our HTML, however, the character > will not be recognized by the browser or will show us one wrong
This happens with a set of characters that are special and that the browser will recognize by using the particular label of this character with the following format &label;
In the example above, the label for the > is gt, starting with & and ending with ;
On the following website we can consult the complete list of the 256 universal characters HTML