sanzuu
sanzuu

Reputation: 192

HTML meta tag must be closed or not in XHTML?

I have a doubt regarding meta tag for below mentioned template

<!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" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" >
<title>Site Name | Page Title</title>
<meta name="keywords" content="Keyword1,Keyword2,Keyword3" >
<meta name="description" content="Page description" >
</head>

Should I closed meta tag like that :

<meta name="keywords" content="Keyword1,Keyword2,Keyword3" />
<meta name="description" content="Page description" />

Upvotes: 0

Views: 5611

Answers (2)

Cornest
Cornest

Reputation: 269

Yes. In XHTML all elements must be explicitly closed.

Difference between HTML and XHTML:

  • In HTML the <meta> tag has no end tag.
  • In XHTML the <meta> tag must be properly closed.

You can use the tags like:

<meta name="keywords" content="Keyword1,Keyword2,Keyword3" >
<meta name="description" content="Page description" >

For more information: http://www.w3schools.com/tags/tag_meta.asp

Upvotes: 2

Quentin
Quentin

Reputation: 943220

Yes. In XHTML all elements must be explicitly closed.

An element with content must be closed with an end tag.

An element which cannot have content (such as <meta/>) can be closed with either an end tag or minimized tag syntax (unless you are writing HTML Compatible XHTML in which case you must use minimized tag syntax).

An element which can have content but does not can be closed with either an end tag or minimized tag syntax (unless you are writing HTML Compatible XHTML in which case you must use an explicit end tag).

Upvotes: 0

Related Questions