How to use HTML5 features with XHTML

I need help with web programming. I have to do this assignment from school, and the professor gave details about structuring. One of them is that my site must comply with XHTML (Strict or Transitional). Another is that I need to use at least one HTML5 function. How to use the HTML5 function if none of the new tags are validated using XHTML?

I declare it as XHTML 1.0 Transitional.

Here is my HTML code where I am having problems.

<body id="index" class="home"> <header id="banner" class="body"> <h1><a href="#">Header1 </a></h1> <nav><ul> <li class="active"><a href="#">home</a></li> <li><a href="#">portfolio</a></li> <li><a href="#">blog</a></li> <li><a href="#">contact</a></li> </ul></nav> </header> </body> 

The title bar and navigation indicate that the elements are undefined and that the id and class attributes are not in the header. Please, help.

Thanks.

+6
source share
2 answers

The interpretation of assignment, which seems to make the most sense, is that you should use the XHTML HTML5 linearization , also known as XHTML5. It just means that you use HTML5, like everyone else, but you do it using common XML principles.

In an example case, this would mean the following markup:

 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> </head> <body id="index" class="home"> <header id="banner" class="body"> <h1><a href="#">Header1 </a></h1> <nav><ul> <li class="active"><a href="#">home</a></li> <li><a href="#">portfolio</a></li> <li><a href="#">blog</a></li> <li><a href="#">contact</a></li> </ul></nav> </header> </body> </html> 

The doctrines of XHTML 1.0 are completely different. They define fixed versions of HTML, so you can’t use in static markup everything that is not allowed by these versions, that is, something new in HTML5 compared to XHTML 1.0 and HTML 4.01 (which is what the “HTML5 function” is probably , means the appointment). The requirement "XHTML-compliant (Strict or Transitional)" is unclear, but if it is specifically intended to reference XHTML 1.0, then the assignment is self-consistent (unless you use client-side scripts to go to the "HTML5 functions").

(This answer has been largely rewritten thanks to comments by @Alohcis.)

+7
source

Depending on your definition of the definition of "HTML5," this is not possible with markup. The document cannot use the new HTML5 element, while remaining compatible with any of the XHTML 1.0 doctrines.

However, if you are allowed to use the JavaScript APIs that were introduced with HTML5, such as localStorage , you can get away with a script entry to access these APIs without using any new HTML5 elements such as <header> or <nav> . These APIs are not tied to HTML5 markup and therefore can be used with any flavor of markup, but are generally called "HTML5 functions" in any case.

+6
source

Source: https://habr.com/ru/post/927211/


All Articles