Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the relationship between XHTML and HTML5 (and on)?

Tags:

html

xhtml

Is there any reason to consider XHTML related details for web development for someone who works with HTML4 and plans to work with HTML5?

Or was XHTML a "side" development in web technology which is not related to the current mainstream of web development (which I guess is HTML5)?


Rationale for asking

The reason I'm asking is that a StackOverflow answer I previously posted was recently commented on to the effect that "You should NOT use upper case HTML tags". When I asked "why" the commenter pointed me to a couple of articles, both of which gave the reasoning for lowercase-only tag names as "Upper case tag names are not allowed in XHTML" as the main reason.

Since I don't currently do web development in XHTML (pure HTML4.0) and only plan to use HTML5 as the next step, I'm interested in whether XHTML should be a factor in assorted decisions I make as far as web development

Please note that this question is NOT asking whether one should use upper or lower case tag names in pure HTML - merely whether the upper-case-tag prohibition in XHTML should be a factor in my decision making, or I should ignore XHTML related rules.

like image 724
DVK Avatar asked May 13 '12 01:05

DVK


People also ask

What is XHTML5 and how does it work?

HTML5 is a newer version of the HyperText Markup Language (HTML) and is considered as an extension of SGML. HTML5 enables JavaScript operations and is used in web page creation and links them from one to the other. It is a widely used markup language on the internet. What is the Difference Between XHTML and HTML5?

What is the difference between HTML and XHTML?

XHTML is a stricter, more XML-based version of HTML. What is XHTML? Why XHTML? XML is a markup language where all documents must be marked up correctly (be "well-formed").

Why use HTML5?

Why Use HTML5? XHTML is not compatible with the IE8 and other older versions of the browsers. HTML5 is capable of using XHTML style tags but not vice versa. While writing code in XHTML, there are several restrictions that the developers need to adhere to.

What is the full form of XHTML?

XHTML stands for Extensible Hypertext Markup Language. It can be considered as a part of the XML markup language this is because of XHTML have features of both XML and HTML. XHTML is extended from XML and HTML.


4 Answers

Most of the info you will find on XHTML fails to mention that the whole purpose of XHTML is to be used by both humans and computers for data exchange. XHTML was created so that computers could talk to each other, but in the same time remain readable by humans. The most crazy thing is that various code monks became obsessed with XHTML compliance, without any intend of using the XHTML for data exchange and without understanding what XHTML actually is.

Edit: A good example of XHTML use is an airline company publishing its flights. The company can utilize XHTML to produce a single list of flights that will be both consumable be humans visiting online and by services that will read the data for their needs.

On the other hand if you own a hair-salon, there is no need for your site to validate against XHTML standards.

like image 152
Registered User Avatar answered Oct 19 '22 06:10

Registered User


Directly, there's no reason to take into account XHTML rules when marking up documents for the HTML serialization of HTML5.¹ However, it seems to be the modern practice to use lower case for tags, and that has been partly influenced by XML and XHTML. So if you find yourself working in a large team of developers, it is quite likely that the coding guidelines for the team will mandate lower case just for consistency's sake. So, it might be worth getting into the habit of doing so.

¹ Note that there's also the possibility of using the XHTML serialization of HTML5, in which case it would matter of course, but I don't think that's what you are asking about.

like image 22
Alohci Avatar answered Oct 19 '22 06:10

Alohci


As far as I can tell, XHTML was intended to be a kind of combination between the features of HTML and the strictness of XML. For example, in HTML you can write <b><i>test</b></i> and the browser won't care, it knows what you meant. Whereas in XHTML that would cause an error and block the entire page from showing.

However most browsers just tolerated errors in XHTML as well, so it became kind of pointless.

Personally, the only reason I can give for choosing to use lowercase tag names rather than uppercase is because I'm too lazy to hold the Shift key and I remapped my CapsLock key to something more useful.

like image 21
Niet the Dark Absol Avatar answered Oct 19 '22 04:10

Niet the Dark Absol


From what I've personally observed about XHTML, the only "benefit" of it is the versatility—for example, it is my understanding that with relative ease, one can create a custom tag/element or attribute and still validate with XHTML.

I see no need for custom tags, since if there isn't one that doesn't fit semantically (though the cases are minimal due to HTML5's improvements in semantic markup), you can just use a div or span and use a class or id to make it "fit." And HTML5 does allow custom attributes anyways.

So I see no direct relationship—or at least, I don't think there should be one—between HTML5 and XHTML (and anyways, XHTML 1.0 is meant to be a combination of HTML 4 and XML). The spec doesn't recommend one over the other, it just notes the fact that in HTML5, they are case-insensitive.

I personally use lowercase tag names for two reasons:

  1. It's a nuisance to hold shift every time (though one could argue that you hold shift to get the angular brackets, but whatever).
  2. It's a style preference—I truly think it looks much cleaner with lowercase tag names as well as a lowercase doctype (<!doctype html>). Uppercase tag names are really old-fashioned, and you don't really see them anymore. It may just be a thing with newer generation programmers such as myself.

And either way, you should pay no mind to rules that apply to a doctype you're not even working with.

like image 1
Purag Avatar answered Oct 19 '22 06:10

Purag