Maybe you have noticed in the previous section that the biggest difference between XHTML files and ordinary plain text files is that they are included with <>, such as <body>. We call them tags. Usually, XHTML tags appear in pairs, such as <html></html>. You can see that they only have one / different. We call labels similar to <html> without / the starting tag, while the corresponding one with / is called the terminating tag, and the terminating tag and the starting tag are only one / symbol different from the starting tag. Of course, there are some tags in XHTML that do not appear in pairs, and they do not terminate tags. We call such tags empty tags. The content of empty tags will be mentioned later in the tutorial.
Previously, HTML tags were not case sensitive, for example, tags <HTML> and tags <html> were equivalent. In XHTML, all tags are in lowercase. In order to make your website meet XHTML standards, you should develop good habits that all tags are in lowercase during the process of creating web pages.
Open the html file saved in the previous tutorial. Put the sixth line on this is my first page. Change this to this is my first <b>web page</b>. , then save and modify and browse the web page again. You will find that the two words on the web page have become bold, with the effect as follows:
This is my first page .
The difference is obvious. The two words on the web page have become bold because they are wrapped in the tag <b></b>. <b>The tag means bold display, and it only affects what it contains. This is how the XHTML tag works. We call the content wrapped by the tag elements. In this example, the two words on the web page are the elements of the <b> tag.
<hr size=1>
We can set some properties for XHTML tags. Please pay attention to the horizontal line above. The original code is: <hr />. In XHTML, the <hr> tag is a horizontal dividing line. We can add an attribute size (that is, the size of the dividing line), and its attribute value is 1. Then its complete code is:
<hr size=1 />
Similarly, the method of adding attributes to other XHTML tags is also added to the starting tag of the tag: attribute = attribute value. It should be noted that attribute values must be enclosed in quotes. Single or double quotes are OK, but double quotes are more commonly used.
Format for adding attributes: <start tag attribute=attribute value> instance-> <table border=none>
Pay attention: Ordinary XHTML files have two level standards (not framework standards) - transition standards and strict standards, among which transition standards are mainly aimed at webmasters who are accustomed to developing websites using HTML. The above code is legal in the transition standard, but in the strict standard, the size attribute will be considered an illegal attribute. XHTML is not only a more standard and strict HTML, but also advocates an idea of building a website. That is to separate the content of the web page from the style, which is achieved through CSS in XHTML. Therefore, we recommend that you use strict standard XHTML to completely hand over the task of defining styles to CSS. (The questions about the XHTML standard will be introduced in the following tutorial)
Maybe you have already paid attention to it. Here we did not write the dividing line label as symmetrical <hr></hr>, but as <hr />. In fact, this is exactly the unpaired tag we mentioned in the previous tutorial. It only has the starting tag <hr> but does not terminate tag</hr>. Since it has no elements, we call such a label a short label. So why do we write it as <hr /> instead of simply <hr>? Such writing formats are to meet the rules that any tag in XHTML needs to be closed. We call the method of adding/ at the end of the starting tag the autism of the tag (or self-closing, self-termination, etc., whatever you like, it is OK). 2 pages in total Previous page 12 Next page