Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I'm about to begin working on a project which involves creating an eBook-like website which will contain lots of large documents with text and images.
The site should have a rather minimalistic design, but it will include a UI with some scripting and animations to make browsing the large documents easier.

I've been thinking on this matter for a while now and I can't decide what markup to use for such a project.
Should it be HTML 4.0 strict? XHTML 1.0 strict? Perhaps HTML5?

It is a likely that people who are not especially internet-savvy will visit the site due to its content, and as such I think it's very plausible for some of the visitors to have relatively old browsers. Can XHTML or HTML5 hurt me in this regard?

Reading about various eBook formats (specifically EPUB), I learned that many of them use XHTML internally; does this mean that if I use XHTML (correctly) the site might also be packaged and delivered as an EPUB in the future? The strictness and cleanliness of XHTML/XML also appeals to me greatly.

Overall XHTML appeals to me the most, but I'm scared about the implication of its use. It has supposedly been discontinued by W3C in favor of HTML 5. However, I don't really see any advantages to using HTML5 over HTML 4 strict, as I won't be using any of it's features. I'm also worried about browser compatiablity of HTML5.

Should I just stick with good ol' HTML 4 strict?

share|improve this question
1  
read up on "responsive design" and have the site switch CSS to respond to the size and type of client. –  Jarrod Roberson Mar 9 '13 at 1:51

4 Answers 4

up vote 2 down vote accepted

HTML 5

The advantages of HTML 5 are the ability to use new tags, more expressive and meaningful than <div>s, and to benefit from a few features added in HTML 5, like better support for forms (with validation of fields, etc.).

Note that you are not forced to use HTML 5 in order to use:

  • styles available in CSS 3, like gradients. You can use CSS 3 with older versions of HTML as well.

  • features related to JavaScript, like web sockets. In the same way, a website written in XHTML 1.1 would still be able to support web sockets.

XHTML

XHTML was published in 2000 to replace HTML by introducing stricter rules. The goal was to make it easier for smartphones and especially mobile phones to parse XHTML code with sparse hardware resources, given that an XML parser is easier to develop compared to an HTML parser (factor which can benefit both the usage on low-end hardware and the adoption of such parser in new programming languages and frameworks).

This attempt failed for a few reasons:

  • Today's iPhone is ways more powerful than a quite expensive desktop PC you were able to buy in 1999. Smartphones are now capable to parse HTML, including non-W3C-compliant HTML, fast enough.

  • Not everyone wrote valid XHTML code. In practice, most people just changed the headers, while keeping the legacy invalid, crappy HTML 4 full of <center> and <p><div></p></div>.

  • Severe issues caused by, on one side, the misunderstanding of the appropriate HTTP headers to use when sending XHTML, and on the other side, the terrible behavior of some well-known browser when it came to recognizing XHTML, made the adoption of XHTML difficult.

One of the advantages of XHTML compared to HTML 4 was the fact that a valid XHTML code was also a valid XML. This made it possible to somehow use XHTML as XML to extract data programmatically from the web page. This scenario is infrequent and I can't even find a good example where such thing would be used, instead of requesting/sending the raw model directly as JSON or XML.

This advantage doesn't exist any longer, since HTML 5 can be generated as a valid XML code¹.

Another minor advantage was to be able to use XML features, like namespaces. I don't recall any situation where namespaces in XHTML were particularly useful and where it would have been particularly difficult to find a workaround in HTML.

HTML 4

The advantage of HTML 4 is that you're sure that even very old browsers support it.

This advantage is very limited:

  • If we talk about perfect support of the standard, then Internet Explorer is out of the game: no matter what HTML version you chose, IE6 and IE7 will have their own understanding of the standard.

  • If we talk about the ability, for the browser, to actually understand and display the web page, any modern and no so modern browser will succeed displaying any low-quality (X)HTML, no matter its version.

    Want a proof? The following code displays perfectly well, even if nobody have any idea about the version of (X)HTML actually used:

    <html>
        <h1>Hello World!</h1>
        <p>Guess, what is the HTML version used in this ugly code?
    </html>
    

Conclusion

In essence, you may use whatever you want. Given your specific requirements, i.e.:

  1. Minimalistic design,

  2. JavaScript support,

  3. Support of legacy browsers,

  4. Ability to use Epub later,

you may use whatever you want. In your case, you don't benefit from any of the versions in particular and any version will fit your needs. The choice would be dictated by:

  • your personal preferences,

  • and, eventually, reasons which are unrelated to the project. For example, if you lack HTML 5 keyword on your CV, this may be a reason to pick HTML 5.


Overall XHTML appeals to me the most, but I'm scared about the implication of its use. It has supposedly been discontinued by W3C in favor of HTML 5.

What do you mean by "discontinued"?

  • HTML 5 has currently a status of Candidate Recommendation, not a W3C Recommendation (REC).

  • XHTML 1.1 is a W3C Recommendation since 2001.

  • HTML 4.01 is a W3C Recommendation since 1999.

Both HTML 4 and XHTML 1.1 are perfectly valid choices from the point of view of the standards. Both HTML 4 and XHTML 1.1 are widely used by the web industry.


¹ “The other syntax that can be used for HTML5 is XML. This syntax is compatible with XHTML1 documents and implementations.” Source: W3C working draft HTML5 differences from HTML4.

share|improve this answer
    
@downvoter: could you, please, comment about what's wrong with this answer? This will give me the opportunity to improve it or to correct/improve the wrong parts, if any. As is, your down vote is not very useful. –  MainMa Mar 9 '13 at 16:04
1  
I didn't downvote, although I almost did. The question is about ebooks, your answer looks like an explanation of HTML history in browsers. –  Florian Margaine Mar 12 '13 at 7:28
1  
@FlorianMargaine: The question is not about an eBook, but about an "eBook-like website", i.e. a specific kind of website => meaning that browser support, not eBook reader support, is relevant. –  jhominal Mar 12 '13 at 8:48
    
Ooh, my bad then :-) –  Florian Margaine Mar 12 '13 at 13:19
    
An extremely informative reply, and other research I've done seems to also show that for my needs there won't be much of a difference between the various DOCTYPEs. Your argument for having HTML5 in my CV (and the fact that I want to be more familiar with it) have made me choose to go with HTML5. Thanks a lot for taking your time to write this answer. –  Acidic Mar 14 '13 at 13:06

XML is the de facto markup language in the world of books and journals. As MainMa points out in a footnote “The other syntax that can be used for HTML5 is XML".

O'Reilly have published a free book about their evolution to 'XML first' (I can't find a link since Chrome and Xmarks screwed my bookmarks ).

Book: A Futurist's Manifesto (A collection of essays from the bleeding-edge of publishing) which you can read for free has some useful chapters. http://book.pressbooks.com/table-of-contents

By all means stick a HTML5 doctype at the top of each page (CV++). Just make sure to stick to XML compliant markup within.

share|improve this answer
    
That is pretty much what I've been thinking about doing. But staying in compliance with XML means that I have to close void elements ('<br/>' and not '<br>'), are there any risks to doing so such as browser support or unexpected behavior? –  Acidic Mar 14 '13 at 13:09

Note that the so-called "HTML5 doctype" doesn't have the number 5 anywhere in it. It will put ALL browsers into strict mode going back to at least IE6 but I can't remember if that's true back to IE4 or not. So using that one covers virtually all the bases including XHTML5.

The HTML5 doctype is forward compatible, as well as backwards compatible, so you might as well use that one.

The only time you should use the XHTML doctype is when you are serving the page as XHTML which most people do not. Just using XHTML syntax does not make a page XHTML compliant. It MUST be served as application/xml+xhtml and I doubt that you are. Serving XHTML as text/html, which most people do, is called "tag soup" and requires the browser to fix-up the XHTML elements to conform, ie, the browser has to figure out what you really meant.

For a comprehensive and excellent read: http://hsivonen.iki.fi/doctype/

share|improve this answer
    
Quirks mode was added to IE 5 on Mac first and IE 6 on Windows. Earlier versions cannot switch. –  toscho Mar 9 '13 at 15:17
<!doctype html>

And your good to go... If you dont use HTML5 features then you don't and you have nothing to be afraid about.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.