So which one to start with, HTML or XHTML? I am a beginner and wants to have solid foundations of markup language but as I started learning I found some people use HTML and some XHTML.
相关问题
- Views base64 encoded blob in HTML with PHP
- Is there a way to play audio on a mobile browser w
- HTML form is not sending $_POST values
- implementing html5 drag and drop photos with knock
-
Why does the box-shadow property not apply to a
XHTML is only useful if you want to autogenerate/manage/validate/etc the HTML code with help of a XML based tool, such as a component based MVC framework (e.g. Sun JSF, Apache Struts, Microsoft ASP.NET, etc) or with XSLT. Parsing/formatting HTML programmatically is trickier than XML, because HTML allows here and there non-closing tags, e.g.
<br>
. XML is much easier to parse/format programmatically because it is required to be well-formed.If you're just starting and/or hand-writing "plain vanilla" HTML, I would recommend to use HTML 4.01 elements with a HTML5 doctype. There's really no need to massage the HTML code into a XML format.
The HTML 5 elements aren't widely supported yet, hence the recommendation to stick with HTML 4.01 elements. The HTML 5 doctype triggers the standards mode in most of the browsers, including IE6. The other benefit of HTML5 is that it allows closing shorttags like in XHTML. Also see HTML5 spec chapter 3.2.2:
Basically, even if you write pure XHTML, using
<!DOCTYPE html>
would still make it valid (and trigger webbrowsers in the correct standards mode).XHTML is pretty much like HTML but non-sloppy. I really can't think of a reason besides laziness not to use it.
HTML 4.01 would be your best bet since learning in stages would allow you to see a clearer picture of whats really happening behind the scenes and deep within the markup. Once you have a clear view and lengthy understanding of the HTML 4.01 you can then move to XHTML 1.0.
When it comes to learning on or the other, there's really rather little between them. XHTML is essentially a subset of HTML that encourages (or rather requires) stricter standards -- specifically, it's an application of the XML standard to HTML. As such, any valid XHTML is also valid HTML (for the most part at least).
In my opinion, the distinction between XHTML and HTML isn't really that important. What is important, however, is to write consistent and efficient markup, and this is what the XHTML standard was designed to encourage. It doesn't matter whether you label you code as XHTML or HTML, just as long as it's well-written.
The main feature of XHTML is simply that it requires a high standard of quality in your code, but this is something you should be doing anyway in HTML.
HTML and XHTML are the same language, with slightly different syntaxes. Once you know one, you know the other.
It really doesn’t matter.
XHTML is for a-type people who think XML looks more "neat" than plain-ol HTML.
But really, it doesn't matter that much. You can switch from using one to another faster than it would take you to get some lunch.