Saturday, November 17, 2012

Answers > What Is the Difference Between HTML, XHTML and CSS?

What Is the Difference Between HTML, XHTML and CSS?

by nForms on December 2, 2011

They say it XHTML and CSS are both extensions of HTML. And when Im starting to make new website there is Doctype I need to choose - either HTML or XHTML..but doesnt matter what I choose I always use the same tags dont I?? I am very confused.

Tags: , , , , ,

Similar XForms | XML Posts

{ 2 comments… read them below or add one }

emailjaredc June 24, 2011 at 9:35 am

The only essential difference between XHTML and HTML is that XHTML must be well-formed XML, while HTML does not. (HTML 4 and earlier were nominally SGML, while HTML 5 defines its own parsing model in great detail.) Some examples of differences this imposes in practice are:

In HTML, some tags (e.g., <br>) are always empty and may not have closing tags. All elements must be explicitly closed in XHTML. XML permits two types of closing tag for empty elements: <br /> and <br></br>. In XML these are interchangeable, and either can be used freely for any tag. However, if XHTML content is to be served under a text/html MIME type to legacy browsers, only the self-closing form should be used for always-empty elements (like <br />), and only the explicit closing tag should be used for elements that are not always empty (like <div></div>). Otherwise, browsers will usually parse the tag incorrectly.
Similarly, HTML permits omitting end tags for some elements, such as <p>. XHTML forbids this.
In HTML, almost everything is case-insensitive, while in XML, all element and attribute names are case-sensitive. XHTML requires all element and attribute names to be lowercase, while in HTML documents it’s common to find uppercase or even mixed-case names.
Various versions of HTML often permit quotes to be omitted from attribute values, e.g., <body lang=en>.[10] In XHTML, all attribute values must be enclosed by quotes, either single or double: <body lang="en"> or <body lang=’en’>.
HTML permits "attribute minimization", where boolean attributes can have their value omitted entirely, e.g., <option selected>. All XML attributes must have explicit quoted values, so in XML this would be written as <option selected="selected">.
Some required elements may be omitted in HTML, in which case they are implicitly added by the parser. For instance, various versions of HTML don’t require <html>, <head>, or <body> tags to be present unless they’re intended to have attributes. On the other hand, in XML the DOM must be determined without having to know which elements are required, so these tags must be specified explicitly.
In addition to these differences, some specifications define only an HTML serialization or only an XHTML serialization. XHTML 1.0 is roughly just an XML serialization of HTML 4.0, but XHTML 1.1, 1.2, and 2.0 have no HTML serialization, while HTML versions less than 4 have no XML serialization. HTML 5 is the first (X)HTML standard designed to support both HTML and XHTML serializations equally.

ReggioLegato June 24, 2011 at 9:35 am

Yes, XHTML is a extension and a platform for HTML which makes HTML coding have certain restrictions you must follow. Use XHTML as your doctype not HTML. CSS is just styling for web pages you don’t have to include it as your doctype but when you use it make sure you use you include the script tag (obviously). CSS makes styling easier as you may be able to modify any tags with text/color styling with 1 line of code but with XHTML you have to make sure you type every <p> tag or whatever tag you are modifying

Previous post:

Next post: