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>
The HR element draws a horizontal rule. This is a block element and does not require a closing tag.
The HTML <hr> tag is used for creating a horizontal line. This is also called Horizontal Rule in HTML.
The <hr> tag defines a thematic break in an HTML page (e.g. a shift of topic). The <hr> element is most often displayed as a horizontal rule that is used to separate content (or define a change) in an HTML page.
Do you close your <img>, <br> and <hr> tags? In HTML5 void elements are not required to be closed, that means <br> and <br /> are treated the same. Nevertheless i prefer to use the latest one to make clear I do not expend a closing tag.
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 validtherefore the best option is to use <hr />
, which is always valid.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With