XHTML introductory learning tutorial: XHTML tag_HTML/Xhtml_web page production

WBOY
Release: 2016-05-16 16:44:33
Original
1143 people have browsed it
Introduction to XHTML tags
Perhaps you noticed in the previous section that the biggest difference between XHTML files and ordinary plain text files is some things included with "", such as . We call them tags. Usually XHTML tags appear in pairs, such as . You can see that they only differ by one "/". We call a tag like without "/" a start tag, and its corresponding with "/" is called a stop tag. The stop tag is the same as the start tag. The starting tag only differs by a "/" symbol. Of course, XHTML also has some tags that do not appear in pairs, and they do not have a terminating tag. We call such tags "empty tags". The content of empty tags will be mentioned in a later tutorial. About capitalization
Previous versions of HTML tags were not case-sensitive. For example, the tags and tags were equivalent. In XHTML, all tags are lowercase. In order to make your website comply with XHTML standards, you should develop a good habit of using lowercase letters for all tags when creating web pages. The role of XHTML tags (element)
Open the html file saved in the previous tutorial. Change "This is my first web page." on the sixth line to "This is my first web page ." Then save the changes and browse the web page again. You will find that the two words on the web page have become bold, and the effect is as follows:
 This is my first webpage.
The difference is obvious. The words "webpage" are "wrapped" in the tags and become bold. The tag is meant to be bold, and it only affects the content it contains. This is how XHTML tags work. We call the content "wrapped" by the tag an element. In this example, the word "webpage" is the element of the tag. Label properties


We can set some attributes for XHTML tags. Please pay attention to the horizontal line above. Its original code is:
. In XHTML, the
tag is a horizontal dividing line. We can add an attribute "size" (that is, the size of the dividing line) to this dividing line, and its attribute value is 1. Then its complete code is:


Similarly, the way to add attributes to other XHTML tags is to add: attribute="attribute value" to the start tag of the tag. Note that attribute values ​​must be "enclosed" in quotation marks. Either single quotes or double quotes are acceptable, but double quotes are more commonly used.
Format for adding attributes: Example ->
Note: Ordinary XHTML files have two levels of standards (not counting framework standards) - transitional standards and strict standards. The transitional standards are mainly aimed at webmasters who are accustomed to using HTML to develop websites. The above code is legal in the transitional standard, but in the strict standard, the size attribute will be considered an illegal attribute. XHTML is not only a more standardized and strict version of HTML, it also promotes a way of building websites. That is to separate the content and style of the web page, which is achieved through CSS in XHTML. Therefore, we recommend that you use strictly standardized XHTML and leave the task of defining styles entirely to CSS. (Issues about the XHTML standard will be introduced in later tutorials) empty label
Perhaps you have noticed that here we do not write the dividing line label as a symmetrical
, but as
. In fact, this is exactly the unpaired tag we mentioned in the previous tutorial. It only has a starting tag
but no ending tag . Since it has no elements, we call such a tag an empty tag. So why do we write
instead of simply
? This writing format is to satisfy the rule that any tag in XHTML needs to be "closed". We call the method of adding "/" at the end of the start tag the self-closing of the tag (or self-closing, self-terminating, etc., whatever you like to call it).
The self-closing method for using all empty tags is the same, which is to add a space and a backslash "/" before the ">" symbol of the starting tag. Spaces are not required, but some browsers cannot recognize
, only
. That's why we added spaces. (I have not encountered any incompatible browsers so far)
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!