What is XHTML and when should it be used?

9

What I know is that XHTML needs to be valid XML. This implies, for example, that all tags need to be closed. For example:

Errado:
<br>

Certo:
<br/>

But what is the use of this? What is it for? When should it be used?

    
asked by anonymous 11.07.2014 / 13:30

3 answers

5

Basically XHTML is an XML-based HTML rephrasing, with all its rules and validations.

What is the use? Some devices do not recognize HTML because it does not have a semantic meaning.

When should it be used? If you want your application to be seen everywhere (TV, palm, mobile, etc.), XHTML is the correct path.

    
11.07.2014 / 13:58
4

XHTML is HTML written according to XML rules. Because XML is much tighter than HTML, the idea is for you to write a syntax without errors. XML is a very generic markup language. Unlike HTML, XML allows you to make your own tags. Today, this does not make as much sense anymore as we have other ways of structuring data, such as JSON, for example.

And that was the big balcony: an XHTML file is an HTML and also an XML. This means that extracting data would be much easier. Imagine that you could extract data from any web page as if you were requesting an XML file. Interesting, but not very useful for that time. Another thing is that for an XHTML to be really useful, it needs to be served with application/xhtml+xml MimeType, which nobody else did. When HTML5 came about because of the rebelliousness of a group of developers linked to various browsers, the scenario changed a lot. HTML5 really solved some of the problems we had in web development for years.

However, since HTML5 is fully backwards compatible, you can use your XHTML today as if it were normal HTML. The XHTML syntax will not break your site and you will be hassle free. Today, no one uses XHTML, so there is no indication or suggestion for you to use in your projects.

    
28.04.2015 / 12:42
2

Another XHTML application is dynamic content generation. You can, for example, interpret with JavaScript an XML file that represents a part of a page. Large-access web applications use this strategy to take advantage of cache . For example, the menu, which is something that does not change often, can be rendered dynamically by a JavaScript from a CSS and XHTML mix, where the XHTML portion is in a .xml file and the formatting in a .css . In this situation it is possible to force the cache of these two files in browser , saving expensive resources such as internet links and processing on web server .

If you can, watch this presentation: link English is relatively easy and the speaker is Udi Dahan, a globally recognized .Net architect. It's worth it!

    
01.08.2014 / 01:58