What type of doctype do you use when writing web pages?

I'm just wondering how to use doctype on Google, Yahoo and Stackoverflow.

And I find that the above 3 sites use doctype HTML4.01:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd" > 

Many say that we should use XHTML1.0 doctype, but the above 3 sites do not. Do you know, why?

I would also like to know what type will be used when writing web pages.

+4
source share
9 answers

I am using HTML5 doctype:

 <!DOCTYPE html> 

Since XHTML does not work on the Internet, and doctype is essentially only good for launching the standardization mode, which the above design works very well in every browser.

+6
source

XHTML is much more rigorous than regular HTML, and therefore it is difficult (or even impossible, depending on the structure you use to create it) to get the right solution. I have seen many web pages that claim to be XHTML and fail on it (silently serving their contents as "text / html", so loading the page in general).

While the whole process of generating HTML, I mean all this, was not distracted by the scope, I dare say that it is impossible to guarantee that the outcome of the process of generating a web page is valid XHTML. But - many popular languages ​​used today (most, I think) build HTML directly, with all the potential errors of people who don’t know by heart in the specification, or just don’t care if the <div> inside the <p> is valid or not.

In addition, it does not have obvious huge advantages over HTML, which would justify its use, especially if you just want to "create a web page to display in a browser."

HTML 4.01 is well supported among user agents and does a good job. Personally, I don’t see a really good reason to switch to XHTML. I am not saying that they are not there, the topic is much more academic than one might think.

+3
source

I always use HTML 4, simply because of the widest compatibility with minimal problems. Also, HTML 4 Strict is mandatory, not Transitional (which is only for outdated pages, not the entire website [which is where it seems to be used, though]). Recently there was a question about SO that dealt with the relative advantages and disadvantages of XHTML over HTML: After all, why choose XHTML through HTML?

+2
source

because IE does not support XHTML and interprets it as HTML ... therefore, some designers prefer to just use HTML 4.01, which is more evenly supported in all browsers.

some reference: http://en.wikipedia.org/wiki/XHTML#Adoption

Most web browsers have mature support for all possible types of XHTML environments. A notable exception is Microsoft's Internet Explorer.

I often use HTML 4.01 just because if I use XHTML and know that on IE it is not interpreted as XHTML, it is strange to keep using it.

+1
source

I use HTML 4.01 Strictly for my personal projects. I'm not worried about sending as application/xhtml+xml , it has full backward compatibility and gives me the technical limitations that I want. I still look like a standard developer, so my code is still clean, although the ML used does not require me (which is a lot).

For me, XHTML seems to have failed a bit. The next most widely used standard in a few years is likely to be HTML5, as the whole XHTML2 project seems to be lagging behind.

I am not saying that it’s bad to use it now. It's just so incredibly rare that you have the advantage of using XHTML instead of HTML. How many XHTML-based web pages do this 100% right now? They mostly fail on the mime type. text/html allowed due to browser compatibility, but still wrong if you look at the whole reason for XHTML. And how much does XHTML functionality really NEED?

I think there are some, but the vast majority of XHTML-based web pages can just change their doctype to HTML 4.01 and work just as well.

So, until I can use XHTML (2?) The way it is supposed (mainly for the MIME type) in all browsers, I just see no reason to use it in HTML 4.01 if my application does not need XML integration. Even then, I would probably think that I’m just making all these changes on the server side and moving from HTML to the template.

+1
source

Backward compatibility is important for these sites. Not so much for Stackoverflow as for Google and Yahoo.

0
source

I would suggest that this is a compromise between standards and compatibility with (essentially) older browsers. Thus, these 3 sites were mistaken in favor of the latter. In addition, some pages do not display properly unless you declare the correct doctype.

0
source

XHTML is probably very difficult to get right if you enable the ability to create user-created content. One inappropriate XML thing is in the wrong place and the whole page will certainly not load.

0
source

If you have access to analytics, I would look at which browsers your audience uses, and then select the DOCTYPE that you think is most suitable. If all your visitors use IE3, you should probably go for some funky old HTML DOCTYPE.

0
source

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


All Articles