Jump to content
  • Advertisement
Sign in to follow this  

[web] HTML - XHTML

This topic is 4718 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Can anyone advise on how much work is involved for someone who knows HTML to learn to use XHTML instead - it seems just a slight syntactical difference on first looking. Is it a big job to make a HTML page validate as XHTML? As a slight side-question, can validating (X)HTML allow you to launch a linked page in a separate window, since the "target" property of hyperlinks is not strictly allowed in HTML (presumably because you shouldn't have any properties what with CSS)? Thankyou.

Share this post


Link to post
Share on other sites
Advertisement
Quote:

Can anyone advise on how much work is involved for someone who knows HTML to learn to use XHTML instead - it seems just a slight syntactical difference on first looking.

It's not much of a big difference, just mostly adding /'s to some of your tags and making your markup look even better and readable.

Quote:

Is it a big job to make a HTML page validate as XHTML?

No, it's not too much of a big job if you know how XHTML works and if you've read up on it. I would suggest the tutorials at w3Schools

Quote:

As a slight side-question, can validating (X)HTML allow you to launch a linked page in a separate window, since the "target" property of hyperlinks is not strictly allowed in HTML (presumably because you shouldn't have any properties what with CSS)?


I'm not entirely sure, I haven't run across this problem yet. The only way to find out is to validate a page using the target="_BLANK" property if I remember it correctly.

Share this post


Link to post
Share on other sites
Here are the basics.

You need a <!DOCTYPE> at the very beginning, like so
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

You can also put information about the xml version used, but the DTD, above, has to be first! <?xml version="1.0" encoding="ISO-8859-1"?>

Don't use deprecated style tags, e.g. <font> <center> <s> <strike>.

Don't use deprecated style properties, e.g. bgcolor, align, type, color, etc.

Don't use frames.

Every property must be enclosed in quotes, so href=http://google.com becomes href="http://google.com"

Every tag must be closed and in proper order. <li> needs </li>, and <a><li> needs </li> before </a>.

For single tags that aren't closed like <img>, you must do this:
<img src="blah.png" />

Voila, XHTML!

And I checked about the target property and it looks like it's not supported in strict XHTML. But if you think about it, you don't really need it.

And other helpful hints are to use CSS fully, stay away from table layouts, and use PNG images.

Peace, Boder

Here is an example of changing HTML to XHTML.


<html>
<head>
<title>My Webpage
<body bgcolor=DarkKhaki>
<h1>What's up World
<center><img src=http://www.google.com/intl/en/images/logo.gif ></center>
<p align=right>I like cheese

</body>
</html>





<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<?xml version="1.0" encoding="ISO-8859-1"?>
<html>
<head>
<title>My Webpage</title>
<style type="text/css">
body {
background-color: #BDB76B;
}
</style>
</head>
<body>
<h1>What's up World</h1>
<div style="text-align:center"><img src="http://www.google.com/intl/en/images/logo.gif" /></div>
<p style="text-align:right">I like cheese</p>

</body>
</html>

Share this post


Link to post
Share on other sites
Quote:
Original post by Boder
And other helpful hints are to use CSS fully, stay away from table layouts, and use PNG images.

Peace, Boder


What's wrong with table layouts? I use them all the time.

Share this post


Link to post
Share on other sites
I use table layouts too now, but HTML purists might say that the <table> tag was meant for tables, not for whole HTML pages. The point is that HTML is a markup language and each tag is suppposed to qualify the content. By using tables for formatting, you are using tables only to make the page look right, when you should be using tables to present scientific data, measurements, comparisons, etc.

HTML shouldn't be used for the presentation, it should only be used to describe the information in the page. The browser should then take care of how to display it. Also tables add a bunch of extra markup with all their <td>'s and <tr>'s.

But I have found that tables often make life much easier and there isn't a suitable replacement for them yet. Talk about the hassle of having a menu on the left that spans the entire height of the page and can change its width without bleeding into the content pane on the right!

Share this post


Link to post
Share on other sites
i've been getting into using css instead of tables recently. i recommend it, makes the html more readable and a lot smaller.

i had to do a test to get a job where they gave me a picture of a page and i had to code it in html. i did it properly using css / xhtml. this is what i did:
http://luke.shellhq.net/lm_task1/task1.html

don't know if it's of use.

Share this post


Link to post
Share on other sites
Quote:
Original post by Ekim_Gram
So, what? Do those people propose that we just use position: absolute for everything now? BALLOCKS!

Tables are for tabulated data, not a layout tool. Now pre-CSS that was pretty much all that was avalible, but with CSS layout control you really shouldn't be using tables. And it makes it much easier to get it working (and to work cross-browser as well).

Share this post


Link to post
Share on other sites
Of course, there are unfortunately some very simple layouts that are trivial with tables and a bitch to get right with CSS.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!