<br />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". For elements in HTML that do not have an end tag, add a "/" before the end to close the tag. For example, the original writing method of the <img> tag in HTML is: <img src="..." alt="..."> In XHTML, you should add a "/" before the ">" to close the tag. In order to prevent some old browsers from not recognizing this writing method, you should add a space before the "/" (HTML compatibility standard): <img src="..." alt="..." /> This seems to mean that adding a "/" to the opening tag will close the tag. Especially for labels in the space, it seems to be more concise to use this method. For example, <div class="clear"></div> This is a piece of code that is often used in clearing floats (closing floating elements). Then it seems that it can be written as: <div class="clear" /> Yes, the <div> element can be empty, and there is nothing wrong with writing it this way, but what consequences will arise if we use similar writing methods for other tags? To import an external JavaScript file into the <head>, we usually write: <script type="text/javascript" src="..." language="javascript"></script> Since there is no empty content, can we write <script type="text/javascript" src="..." language="javascript" /> We found that this way of writing either does not work or results in errors in the browser. In most cases, the browser will think that the tag is not closed and mistakenly recognize that all content after <script> is Javascript code, which will cause an error. For example, <textarea id="tt" cols="10" rows="8" /> If you run this code in a browser, you will find that starting from <textarea>, all the XHTML codes after that will be treated as the content of the text box and appear in the text box. It seems that the paired tags that already exist in HTML4.0 must use the existing end tags in XHTML. So why is <div> okay? In fact, <div> is not allowed either, it’s just that <div> is not displayed so clearly in the browser. Writing methods such as <span /> are even more incorrect. First of all, <span> itself has a closing tag </span>. In addition, the content of the <span> tag cannot be blank (even pure spaces are not allowed). That is to say, except for tags such as <img>, <hr>, <link>, and <br>, which can be closed with “/”, other elements must use </...>, otherwise unexpected problems will occur. |
<<: How to install tomcat in docker and deploy the Springboot project war package
>>: How to solve the problem that Seata cannot use MySQL 8 version
1. What is a proxy server? Proxy server, when the...
For Windows User Using openGauss in Docker Pull t...
In many cases, large and medium-sized websites wi...
MySQL stored procedures, yes, look like very rare...
Database Command Specification All database objec...
The content property was introduced as early as C...
In HTML pages, we sometimes need to automatically ...
Front-end is a tough job, not only because techno...
This article example shares the specific code for...
Table of contents 1. Principle Overview Query Cac...
The Internet is already saturated with articles o...
When I first came into contact with docker, I was...
Table of contents 1. Introduction 2. Basic Concep...
When developing a web project, you need to instal...
Method 1: Use the lsb_release utility The lsb_rel...