Languages Related with HTML is the section 17, as well as the final section of Beginner’s Guide to HTML.
XHTML is HTML written as XML or else we can say HTML defined as an XML application. It stand for EXtensible HyperText Markup Language. It also supported by all major browsers. Stricter and cleaner version of HTML and almost identical to HTML 4.01.
Why XHTML emerged?
Many web pages on the internet contain “bad” HTML. Bad in the sense, no proper standard in the code that written. It may display correctly, but the code is really not good. No closing tages, jumbled with upper and lower cases kind of stuff.
To avoid that XML (EXtensible Markup Language) comes to help. XML is a markup language where documents must be marked up properly and must be “well-formed”. You know what the well-formed means, aren’t you? Surely it does like the well formed dress code. Today’s computer industry consists of different browser technologies. Some browsers run on computers, and some are run on mobile phones or other small devices. Smart Phones, Laptops, Tabs and Pads. Smaller devices often lack the resources or power to interpret a “bad” code. Therefore, XHTML was developed by combining the strengths of both HTML and XML. We can say XHTML is HTML redesigned as XML.
HTML Vs XHTML
In XHTML there are several restriction. You cannot deal with it as the same like HTML. XHTML is a tough guy. Let’s look at one by one what are the restrictions in XHTML.
- XHTML DOCTYPE is mandatory
- If you can remember I said, in HTML it is really not necessary to include in the Writing Your HTML Code section. Go back to that section and see how the doctype need to be written on a XHTML document. You can open a HTML file in a browser without the doctype tag, but cannot open a XHTML file without it.
- The xmlns attribute in is mandatory
- What the heck is this xmls attribute? To learn about that you have to look into our xml tutorial. For your information, I just say it means the xml name space for the document.
- , ,
, andare mandatory
- Browsers need the element in the document to process the content as HTML. So does XHTML.
- Must be properly nested
- In the Writing Your HTML Code, we disscussed about nested elements. See the following example.
This text is bold and italic. Opps!!
This text is bold and italic
- In the Writing Your HTML Code, we disscussed about nested elements. See the following example. [code language=”html”]
- Must always be closed
- Not only the pair elements but also the empty element. But for the HTML it doesn’t matter as we said in the Writing Your HTML Code section.
Oops!! Your paragraph
- Not only the pair elements but also the empty element. But for the HTML it doesn’t matter as we said in the Writing Your HTML Code section. [code language=”html”]
- Must be in lowercase
- Must have one root element
- Attribute names must be in lower case
- Attribute values must be quoted
- Attribute minimization is forbidden
- When creating the drop down list using the
If you want to check your HTML file is XHTML compatible, follow this URL. http://validator.w3.org You can validate your HTML document online. Keep in mind, the above points are mandatory and must in XHTML.
This script below added/change the attribute style in the paragraph element 'demo'. The added inline style is the font size of the paragraph with the size of 25 pixels.[code language="html"]
This is a Paragraph
The following script changes the image me.gif into picture.gif.[code language="html"]
CSS - Cascading Style Sheets
CSS or HTML styles used to style HTML elements. CSS was introduced together with HTML 4, to provide a better way to style HTML elements. CSS can be added to HTML in the following ways:
- Inline - using the style attribute in HTML elements
- Internal - using the