问题描述
我的同事并不真正了解或理解html。她的工作是向CMS输入信息,我注意到她一直关闭她的< hr />
标签,例如< hr> < / h>
。
我有一个Google,但是我找不到任何说不允许或不可以的地方造成问题。我知道它应该是< hr />
,但值得告诉她吗?或者它是不必要的但是有效的标记?
NB我们网站的doctype是
XHTML 1.0 Transitional
,如果这有什么区别的话。
编辑
@Jeff对验证有个好主意。我使用了以下代码,显然这是有效的XHTML 1.0 Transitional
<!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>
< hr>< / hr>
< / body>
< / html>
OK,< hr> ;< / hr>
实际上也是一个有效的XHTML 1.0。
-
< hr />
有效 -
< hr>< / hr>
有效 -
< hr>
有效
...对于HTML 4.0:
< hr />
有效
< ; hr>< / hr>
是不是有效
< hr>
有效
因此最好的选择是使用< hr />
,它总是有效的。
My colleague doesn't really know or understand html. Her job is to input information into the CMS and I've noticed she keeps closing her <hr />
tags like this <hr></hr>
.
I've had a Google but I can't find anywhere that says this isn't allowed or could cause problems. I know it's supposed to be <hr />
but is it worth me telling her or is it unnecessary but valid markup?
NB The doctype for our website is XHTML 1.0 Transitional
if that makes any difference.
EDIT
@Jeff had a good idea about validating. I used the following code and apparently this is valid XHTML 1.0 Transitional
<!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>
<hr></hr>
</body>
</html>
OK, <hr></hr>
is actually a valid XHTML 1.0, too.
So, for XHTML 1.0:
<hr />
is valid<hr></hr>
is valid<hr>
is not valid
... for HTML 4.0:
<hr />
is valid<hr></hr>
is not valid<hr>
is valid
therefore the best option is to use <hr />
, which is always valid.
这篇关于可以使用< hr />元素有一个结束标记?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!