HTML5 (XHTML style strict format of coding)

687 views Asked by At

Like the title says, what exactly does that mean? Ive tried googling for answers but I still dont understand? so the entire document has to be in a HTML5 format right? and the syntax has to be in strict XHTML?

so is this the correct header to use in this situation? Thank you so much :)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
       "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.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>Page Title</title>
       <link rel="stylesheet" href="style.css" type="text/css" media="screen" charset="utf-8"/>
</head>

<body>

</body>

</html>
3

There are 3 answers

1
alexander farkas On BEST ANSWER

I think you are looking for polyglot HTML5. It's still HTML, but "could be served" as XML.

This is how the base structure looks like:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  <head>
    <title>title</title>
  </head>
  <body>
  </body>
</html>

Here is another article: http://www.xmlplease.com/xhtml/xhtml5polyglot/

1
Stefano Sanfilippo On

The normal doctype (see HTML syntax - doctype) for HTML5 is:

<!DOCTYPE html>

You can also use deprecated doctypes, but the term says pretty much everything about them.

And, no, HTML5 markup does not need to be valid XHTML, in the empirical sense that HTML5 markup might be both valid HTML and non-valid XHTML/XML.

Three meaningful considerations are:

  1. in HTML5 <br> is allowed and <br/> is too.
  2. a closing /> on non-void elements does not behave like it does in XML: it's ignored, you cannot have auto-closing entities.
  3. HTML5 introduces a set of so-called semantic tags (nav, footer, article...), that are not specified in XHTML.

Regarding point 2, this is not valid:

<!DOCTYPE html>
<html>
    <head><title>Dummy</title></head>
    <body>
        <div/>
    </body>
</html>

you have to write:

<!DOCTYPE html>
<html>
    <head><title>Dummy</title></head>
    <body>
        <div></div>
    </body>
</html>

See HTML syntax - elements for more information.

0
Daniel On

check the required syntax of each element in HTML5 according to web specs

http://w3-video.com/Web_Technologies/HTML5/index.php provides a syntax section for each element: e.g.

http://w3-video.com/Web_Technologies/HTML5/doctype/html5_doctype_syntax.php