• Top Members
    Reps
    Posts
  • 834 Replies
    2585 Replies
  • 716 Replies
    2025 Replies
  • 331 Replies
    1928 Replies
Our minions are trying to make the site more secure by encasing the server in a cage made of solid SSL-ium which may throw up some issues when using the site for the next few hours. Bear with us while we weld this thing together and we are sorry for any inconvenience this may cause.

XHTML - For beginers

User avatar
reececlarke
VIP - Donator
Posts: 244

XHTML - For beginers

Thu Feb 18, 2016 12:12 pm

What makes XHTML different from html
The biggest difference between the two is standardization html can be written in quite a shoddy format and still be accepted by the web browser however with XHTML if your code does not conform with the standards then the webpage will refuse to show and will point out to where the error is located.

What are the benefits of using XHTML?
The main benefits of using XHTML come into practise when you are set standards to conform to e.g. in the workplace. If we look past things such as the inability to write sloppy code, this also helps those with special browsers to help with poor sight or lack of it, which are designed to read pages written in xhtml, as those who conform to the standard closer make it easier for the software to display the information in a easy to read manor, as opposed to a poorly written html page which would still load however it might be displayed poorly in the software making it harder for someone with disabilities to read.
What are the big difference between XHTML and HTML?
One of the big differences between the two is that you have to end single tag elements an example of this can be found within the <img> tag in the example shown below

HTML

Code: Select all

 <img src="GenericImage.png"> 
XHTML

Code: Select all

<img src="GenericImage.png" alt="A cool generic image" />
For XHTML we first have to point out the alt which is shown within the tag, this is required in order to conform to the format as it is used to point out to those who are less able to still use the content you provide. Second of all before the end we can also see' />', this is because we have to inform the browser the end of every element, even if it is contained within a single tag. Other examples of this include '<br />', which stands for a line break, although it is dis-advised to use this as CSS should be used for all formatting.

One of the next big differences between HTML and XHTML is that we have to inform the browser within each webpage what standard we are using for us this would be XHTML1.0 strict and the following bellow should be the base for every XHTML webpage you create.

Code: Select all


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">


<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
		<title> Site Name</title>
		<meta http-equiv="X-UA-Compatible" content="IE=edge" />
		<meta name="viewport" content="width=device-width; initial-scale=1.0" />
		
	</head>
	<body>
		<!-- All content for the site should be in here and only within here -->
	</body>
</html>

as we are using a xml format for creating the site without telling this to the web-browser it will have no clue as to what it is doing and there for will not render the page unless you tell it the standards you are using.

The next big difference is unlike within html you are able to just like the style sheet within the head and be done with it within xhtml you have to inform the browser what type of link it is as shown below.

Code: Select all


<link rel="stylesheet" type="text/css" href="linkToStyleSheet.css" />

How do i check if my page is valid?
The simplest way in order to make sure that your web page is valid you could go to the W3Schools validator which is linked here http://www.validator.w3.org
Last edited by reececlarke on Thu May 12, 2016 8:02 am, edited 2 times in total.
Image

User avatar
Codex
Coding God
Posts: 2025

Re: XHTML - For beginers

Fri Feb 19, 2016 3:06 am

Is it possible to list out the pros of using xHTML as well? I guess there are benefits of using xHTML otherwise everyone would've just used normal html and ignored all the errors (and still have the page displayed)
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender

User avatar
reececlarke
VIP - Donator
Posts: 244

Re: XHTML - For beginers

Sun Feb 21, 2016 11:47 am

Codex wrote:Is it possible to list out the pros of using xHTML as well? I guess there are benefits of using xHTML otherwise everyone would've just used normal html and ignored all the errors (and still have the page displayed)
Fair point I will have to add that as it is mostly down to industry standards and allowing your site to be easily accessed by those with disabilities.
Image

User avatar
mikethedj4
VIP - Site Partner
Posts: 2576

Re: XHTML - For beginers

Tue May 10, 2016 8:15 pm

reececlarke wrote:HTML

Code: Select all

 <img href="GenericImage.png"> 
XHTML

Code: Select all

<img href="GenericImage.png" alt="A cool generic image" />
NOTE: Image tags don't have an href attribute (another source)
Image
Image

User avatar
reececlarke
VIP - Donator
Posts: 244

Re: XHTML - For beginers

Thu May 12, 2016 8:03 am

mikethedj4 wrote:
reececlarke wrote:HTML

Code: Select all

 <img href="GenericImage.png"> 
XHTML

Code: Select all

<img href="GenericImage.png" alt="A cool generic image" />
NOTE: Image tags don't have an href attribute (another source)
corrected, slight derp on my part there
Image

Post Reply

Return to “Tutorials”