The hypertext document is divided into two parts: document header and document body. In the document header, some necessary definitions are made for this document, and the various document information to be displayed in the document body.
<HTML>
<HEAD>
Header information
</HEAD>
<BODY>
Document body, text part
</BODY>
</HTML>
Where <HTML> is at the outermost layer, it means that the content between the tags is an HTML document. We will also see some Hompage omitting <HTML> tags, because the .html or .htm file is defaulted to HTML documents by the web browser. <HEAD> includes the header information of the document, such as the document's general title, etc. If the header information is not required, this mark can be omitted. The <BODY> tag is generally not omitted, indicating the beginning of the main content.
Here is the source code for a most basic hypertext document:| <HTML> <HEAD> <TITLE>A simple HTML example</TITLE> </HEAD> <BODY> <CENTER> <H3>Welcome to my homepage</H3> <BR> <HR> <FONT SIZE=2> This is my first time doing a homepage. No matter what, I will work hard to do it well! </FONT> </CENTER> </BODY> </HTML> | ━┓ ┃File header ━┛ ━┓ ┃ ┃ ┃ ┃File body ┃ ┃ ┃ ┃ ━┛ |
The biggest obstacle I encountered when I first came into contact with hypertext is some sentences enclosed with < and >. We call them labels, which are used to divide and mark the elements of the text to form the layout of the text, the format of the text and colorful pictures.
1. Single tag
Some tags are called single tags because they can express meanings completely by just using them alone. The syntax of such tags is:
<Tag Name>
The most commonly used single tag is <BR>, which means a newline.
2. Double label
Another type of tag is called a double tag. It consists of two parts: the starting tag and the tail tag, which must be used in pairs. The starting tag tells the web browser to start executing the function represented by the tag from here, and the tail tag tells the web browser to end the function here. Adding a slash (/) before the start label becomes the tail mark. The syntax for this type of tag is:
<Tag> Content</Tag>
The content part is the part that is to be exerted by this marker. For example, if you want to highlight the display of a certain text, put the text in a <EM> </EM> tag:
<EM>First:</EM>
3. Tag properties
Many single and double tags can contain some attributes in the first tag, and the syntax is:
<Tag Name Attribute 1 Attribute 2 Attribute 3… >
There is no order between attributes, and attributes can also be omitted (that is, the default value). For example, a single tag <HR> means drawing a horizontal line at the current position of the document, which is generally drawn from the leftmost end of the current line in the window to the rightmost end. With some attributes:
<HR SIZE=3 ALIGN=LEFT WIDTH=75%> Where the SIZE attribute defines the thickness of the line, the attribute value takes an integer, missing is 1; the ALIGN attribute represents the alignment method, which can be LEFT (left aligned, default value), CENTER (center), and RIGHT (right aligned); the WIDTH attribute defines the length of the line, which can be taken as a relative value, (the percentage enclosed by a pair of signs indicates the percentage of the entire window), or the absolute value (the number of screen pixels represented by integers, such as WIDTH=300), and the default value is 100%. 2 pages in total Previous page 12 Next page