<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
This article records the installation and configu...
Table of contents JS Three Mountains Synchronous ...
Table of contents Preface Simulating data Merged ...
answer from stackflow: Simply <br> is suffic...
Pull the image docker pull mysql View the complet...
What is Publish/Subscribe? Let me give you an exa...
For individual webmasters, how to make their websi...
To improve the performance of web pages, many dev...
background Sometimes we need to get the creation ...
Preface The reason why MySQL's innodb engine ...
After Vmvare sets the disk size of the virtual ma...
Recently, I need to make a back-to-top button whe...
1. Introduction Earlier we introduced the rapid d...
1. To develop web responsively, the page must ada...
You can have the best visual design skills in the...