Jump to content
xisto Community
Saint_Michael

Saint Michael Xhtml Tips And Tricks #1 xhtml= html 5.0 :P

Recommended Posts

Well by the many views i have seen on my web design issues i should go into new territory, so im going start with some useful xhtml info for you web design fenatics, the info i present to you is from other websites so be warned it might or might not work all depends but lets start off with the basic info for using xhtml. Also this tutorial is for beginners so i won't be doing any xml info due to it being a more server side then actually webdesign

 

1. DOCTYPE this is used to tell the browser what kind of infomation it will be displaying. nothing as really changed from html 4.01. so here is the low down on the doc types

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://forums.xisto.com/no_longer_exists/;

 

XHTML Transitional DTD

Use this DTD when you need to use XHTML's presentational features because your readers don't have browsers that support Cascading Style Sheets (CSS):

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://forums.xisto.com/no_longer_exists/;

 

XHTML Frameset DTD

Use this DTD when you want to use frames! (like anyone uses frames anymore -_-)

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://forums.xisto.com/no_longer_exists/;

 


2.XHTML elements must be properly nested- which means that where the tag starts it should end the same way. look at the example and you know where im getting at

<b><i>This text is bold and italic</i></b>

 


3.XHTML documents must be well-formed- this is simply saying that it begins with <html> and ends in </html> example

<html>

<head> ... </head>

<body> ... </body>

</html>

 

4.Tag names must be in lowercase-THIS IS SIMPLE DO NOT CAP YOUR TAGS LIKE THIS :D

 

5.All XHTML elements must be closed- if you start a tag you must also close even if it the worlds most complex design, so pay attention where your start tag begins or if you like me and want to validate your website it will come out as an error and then you have to figure out why or why is it not validated.

 

6. Empty Elements Must Also Be Closed- well to many of your disappointment the following tags must be closed as well

<br><br />

<hr><hr />

and for those who use images some changes have been made to how it is set up so take a look at the update img tag format

 

<img src="happy.gif" alt="Happy face" />

 

as you can see it is now required to have alt tag in your image and need to be quoted which brings us to NUmber 7.

 

IMPORTANT Compatibility Note:

To make your XHTML compatible with today's browsers, you should add an extra space before the "/" symbol like this: <br />, and this: <hr />.

 

7.All vaules in your tags must be quoted or it will show up as an error on validation

 

8.Javascripting in xhtml for those who use javascripts in their website except those who are in the corprate world (php, asp, perl) javascripting change a little bit but not much, if you use css scripts or you actually used js files then you know what im talking about but if it something simple say for an example a clock, then you have to little cut and paste. The Problem with javascripting in xhtml from my understanding is that the programming is going to pop up errors no matter how hard you try to hack and slash to make sure nothing goes wrong its going to come out an error unless your a programming genius but anyways here are the steps for you novices out their i tried a few out i got it to work some didn't but it depends of on what your using for a javascript

 

STEP #1

cut out the following tags in your javascript

<script LANGUAGE="JavaScript">

and

</SCRIPT>

 

STEP #2

open a text file This is where the problem will start if your using javascripts that have 2 parts first part in the header and the second part in the body then about 90% of the time the javascript won't work so pick your scripts wisely

 

STEP #3

copy and paste and save as date.js thats the easy part thier now just like css somewhat you have to comment the javascript as you can see here or it won't start. and the next easy part saving the txt file. for those who use editors it should show up as a js file but if your hardcore and use note pad make sure you save it using the .js or its not going to kick in.

<!-- hide script from old browsers

 

test = new Date()

month = test.getMonth()

month = (month * 1) + 1

day = test.getDate()

year = test.getFullYear()

document.write(" ",month,"/",day,"/",year," ")

 

// end hiding script from old browsers -->

 


STEP #4

put the following tag on your website now to finish off this process its as easy as 1234 steps :D. now you put this tag anywhere on your website and it should not conflict with your xhtmlm validation mind you it might not work if the script is 10mb long.

<script src="date.js">

</script>

 


their you have it you just made a js file for using xhtml formant and now to finish issue #1 the comment tag, we all now what it is but for those who just lost their mind here you go

<!-- Insert Comment here-->

 

using that format is now invalid if your xhtmling they changed it quite a bit, don't see why but hey its programmin so here is what the new comment tag looks like

<[CDATA[comment goes in here]]>

 


Share this post


Link to post
Share on other sites

I'm glad someone posted this. XHTML has strict, but acceptable guidelines for markup. Everyone needs to be doing the same thing, so as to easily consult others when troubleshooting or presenting information.

Also, I should point out your explanation of Javascript in XHTML. Javascript definitely works correctly in XHTML Strict, Trnasitional, etc. When you have a Javascript that you want in your page, and you link to it externally, you need to make sure you put the "header" part of your script in a seperate file and link to it in the header like so:

<script language="javascript" src="header_part.js"></script>
And if your javascript has a body part as well, you would call the other file with just the body part in it in the <body> tag of your document in the same fashion.

Also you should point out that tag values must be in quotes and must be lowercase. So the following would be incorrect in a number of places (not a single value or attribute is correct):
<img src=file.jpg width=510 HEIGHT=100 alt=Hey align=CENTER />
The correct way would be:
<img src="file.jpg" width="510" height="100" alt="Hey" align="center" />

Share this post


Link to post
Share on other sites

<img src="file.jpg" width="510" height="100" alt="Hey" align="center" />
The more correct way of doing this would to take align="center" out of your image tag and apply it to your CSS instead:
img { text-align: center; }

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.