正确关闭或自动关闭HTML5中的标签 [英] Properly closing or self-closing tags in HTML5

查看:740
本文介绍了正确关闭或自动关闭HTML5中的标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个关于关闭自动关闭的HTML标签的问题。

哪个更合适?

  1。 < meta http-equiv =Content-Typecontent =text / html; charset = utf-8> 
2.< meta http-equiv =Content-Typecontent =text / html; charset = utf-8/>
3.< meta http-equiv =Content-Typecontent =text / html; charset = utf-8/>

另外,如果任何人对这个< meta> 标记,例如:

 < meta http-equiv =X-UA兼容内容=IE = edge/> 



$ b

差异 - 如果meta-http-equiv-x-ua-compatible-content-ie-edge-e>这篇文章对我有所帮助。



我为我的文档类型使用<!DOCTYPE html>

解决方案

HTML5 中,关闭某些 HTML标签并不是绝对必要的...(但有些标签)



输入 w3。组织


8.1.2.1开始标记

...

...

6)然后,如果元素是 void elements ,或者如果元素是 foreign元素,那么可能会有一个/(U + 002F)字符。此字符对无效元素没有影响,但在 foreign元素它将开始标记标记为自动关闭



I have a question relating to closing HTML tags that are self-closing.

Which is more proper?

1. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
2. <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

Also, if anyone has a good alternative for this <meta> tag, for example:

<meta http-equiv="X-UA-Compatible" content="IE=edge" />
OR
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

This article helped me some-what.

I use <!DOCTYPE html> for my doc type.

解决方案

In HTML5 it is not strictly necessary to close certain HTML tags... (but some does)

Form w3.org:

8.1.2.1 Start tags
...
...
6) Then, if the element is one of the void elements, or if the element is a foreign element, then there may be a single "/" (U+002F) character. This character has no effect on void elements, but on foreign element it marks the start tag as self-closing.

这篇关于正确关闭或自动关闭HTML5中的标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆