\" a Valid Way to Close an HTML Span Tag? " />" a Valid Way to Close an HTML Span Tag? " />
Can an HTML Span Be Closed with ""?
The validity of closing an HTML span with "" hinges on the doctype used.
XHTML
In XHTML, which adheres to XML standards, all major browsers recognize self-closing tags like "". For instance, consider the following valid XHTML code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> <h2>Will test page</h2> <p>some stuff <span class="drop" /></p> </body> </html>
HTML (Non-XHTML)
In contrast, when using HTML without the XHTML doctype, "" is not a valid self-closing tag. Take this HTML example:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body> <h2>Will test page</h2> <p>some stuff <span class="drop" /></p> </body> </html>
This code will not validate because spans must be properly closed with "".
Additional Notes:
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3