XHTML tags have a closing tag_HTML/Xhtml_Web page production

WBOY
Release: 2016-05-16 16:45:36
Original
2055 people have browsed it

Original link: http://www.dudo.org/article.asp?id=253
There is a standard in the XHTML specification that "each XHTML tag has a closing tag". Then for elements in HTML that do not originally have an end tag, add "/" before the end to close the tag. For example, the original way of writing the XHTML tags have a closing tag_HTML/Xhtml_Web page production tag in HTML:
XHTML tags have a closing tag_HTML/Xhtml_Web page production
In XHTML, you should add a "/" before ">" to close the tag. In order to prevent some old browsers from not recognizing this writing method, you must add a space before "/" (HTML Compatibility standards):
XHTML tags have a closing tag_HTML/Xhtml_Web page production
This seems to mean that adding a "/" to the opening tag can close the tag. Especially for empty tags, it seems more concise to use this writing method. For example,

This is a piece of code often used in clearing floats (closing floating elements). Then it seems that it can be written like this:

Yes, the
element can be empty. There is no problem in writing it this way, but what are the consequences if we use similar writing methods for other tags? If we introduce an external Javascript file in , we usually write it like this:


Since there is no content and it is empty, can we write it as
<script> We found that this way of writing either doesn’t work in the browser or will cause an error. In most cases, the browser will think that the tag is not closed, and mistakenly recognize that all the content after <br /> is Javascript code. So an error will occur. Another example, <textarea id="tt" cols="10" rows="8" /><br /> <textarea> If you run this code in the browser, you will find that starting from <br />, all subsequent XHTML codes will be treated as the content of the text box and appear in the text box. <div> It seems that paired tags already exist in HTML4.0 and existing closing tags must be used in XHTML. So <div> why is it possible? In fact, <div> is not possible either, it’s just that <span /> is not displayed so clearly in the browser. Writing methods such as <span> are even more incorrect. First of all, itself has a closing tag <span>. In addition, the content of the <img alt="XHTML tags have a closing tag_HTML/Xhtml_Web page production" > tag cannot be blank (pure spaces will not work either). That is to say, except for <hr>, <link>, <br>, tags have a closing tag_HTML/Xhtml_Web page production> and other tags that can be closed with "/", other elements must use <script type="text/javascript" src="XHTML tags have a closing tag_HTML/Xhtml_Web page production" language="javascript"></script>, otherwise unpredictable problems will occur.
Related labels:
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