<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
Table of contents 1. Introduction to MySQL Index ...
When using Nginx as a Web server, I encountered t...
1. docker ps -a view the running image process [r...
Experimental environment: 1. Three CentOS 7 serve...
Ubuntu is a relatively popular Linux desktop syst...
at at + time at 17:23 at> touch /mnt/file{1..9...
Install axios and implement communication Here we...
introduce You Yuxi’s original words. vite is simi...
Shtml and asp are similar. In files named shtml, s...
This article shares the specific code of React to...
Mysql slow query explanation The MySQL slow query...
1. Download the accelerated version of msyql dock...
Table of contents 1. What is block scope? 2. Why ...
Table of contents Portainer manages multiple Dock...
animation-name animation name, can have multiple ...