Why is it important to validate your code?

teammatt3's picture

He has: 2,102 posts

Joined: Sep 2003

Why is it so important to make sure your code is validated? I know it is the correct way to do things, but what are the other benefits of doing it?

openmind's picture

He has: 945 posts

Joined: Aug 2001

Well for one it will make you a good person and ensure that you go to webbie heaven!

Seriously though, murder is wrong as is robbery as there are laws that say so. Same goes for standards so we shoud all make the effort to follow them. Not to mention that you code will be faster, cleaner, easier to undertsand, cross browser compatible, friendly to those with disabilities, future proof, etc, etc, etc

KarenArt's picture

She has: 354 posts

Joined: May 2001

... cause chicks dig valid code! Wink Laughing out loud

In reality, there are a few browsers that will let you get away with sloppy coding and will still display the page (although it may look different than you intended depending on how sloppy the code is). The more the browser obeys web standards (I love Safari for the Mac), the more likely it is that your page will look wrong or won't display at all.

As we're getting into newer and newer browsers, the chances of unclean code working is getting less and less. And too... if you're looking for a consistant look cross-browser, it becomes more important to know and use valid coding.

Another thing to be aware of (and avoid) for cross-browser compatibility... browser specific coding (usually something you see IE doing).

Quote: Well for one it will make you a good person and ensure that you go to webbie heaven!

LOL... I love this! Laughing out loud

gotta finish redesigning my sites so I can show them again.

The purpose of education is... to get more jokes!

openmind's picture

He has: 945 posts

Joined: Aug 2001

KarenArt wrote: ... cause chicks dig valid code! Wink Laughing out loud

You'll have to check out my css scripting! Wink

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

KarenArt wrote: ... cause chicks dig valid code! Wink Laughing out loud

In my experience, no. Sad

Matt, it just makes sense to write valid code. Fundamentally, it's more about creating semantic markup, allowing the document can be "self-aware" -- that is, to give meaning to its content in any outside context. Or that's the ideal, at least. It's a step towards XML.

Current standards attempt to rid code of a lot of information noise such as browser and display hacks, and moving styling info to CSS. On a practical level, this gives you faster, cleaner, accessible, easier to maintain, efficient code.

Busy's picture

He has: 6,151 posts

Joined: May 2001

KarenArt wrote: ... cause chicks dig valid code!

Abhishek Reddy wrote: In my experience, no. Sad

Dang, there goes my new pick up line
Confused

He has: 578 posts

Joined: Jun 2004

Beat me to my own joke, Busy.

He has: 1,380 posts

Joined: Feb 2002

For your own personal bragging rights to your friends...

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

Industry standards. Know what you're doing. Quit being a hack, be a forward thinking productive member of the industry.

Roo's picture

She has: 840 posts

Joined: Apr 1999

As someone who has just recently given up WYSIWYG and started hand coding to standards, I have to say it feels good to know that I am doing the best I can do for my clients. I've been spending a lot of time at the W3C school, and am now working on streamlining my css skills.

Things I'm noticing:
While before everything worked fine in 6 different browsers, I find there is less twakage needed. Pages are loading faster.

The downside:
When you have a client who uses Front Page and Word to add content to their own sites, and you've created valid xhtml and css.....watch out............you are going to have a mess to clean up.

Roo

Roo's picture

She has: 840 posts

Joined: Apr 1999

Oooooooooops I wasn't done!

Less tweakage means that I cut the time spent down, and I'm able to hand off a site sooner, cutting the cost for the client, and freeing me up for other things.

I'm also currenlty looking at all of the things you can do to make a site accessable, and it's easier to pass accessabilty tests when you start out with standard code.

I do have another downside though......some javascripts, and php scripts will cause a page not to validate. It's frustrating, and unless you are really adept with programmimg languages it can be VERY frustrating.

Roo

Abhishek Reddy's picture

He has: 3,348 posts

Joined: Jul 2001

Roo wrote: I do have another downside though......some javascripts, and php scripts will cause a page not to validate. It's frustrating, and unless you are really adept with programmimg languages it can be VERY frustrating.

Absolutely, I have trouble with this too. It's why my personal site doesn't validate. Very frustrating. Mad

KarenArt's picture

She has: 354 posts

Joined: May 2001

Hmmm... well javascript, php, and assorted validating problems just gives you more reasons to take the codes apart and figure out what it doing right? Wink
I understand that frustration! I cringe everytime I have a new javascript or cgi code I need to put on a site. Everything always seems to need fixing. Roll eyes

gotta finish redesigning my sites so I can show them again.

The purpose of education is... to get more jokes!

teammatt3's picture

He has: 2,102 posts

Joined: Sep 2003

Thanks for the input, I guess I better shape-up and start coding to standards Smiling

openmind's picture

He has: 945 posts

Joined: Aug 2001

Good man! Welcome to the professionials! Laughing out loud

Busy's picture

He has: 6,151 posts

Joined: May 2001

Most PHP and Javascript will validate, just a case of & instead of & and lower case names/values etc

KarenArt's picture

She has: 354 posts

Joined: May 2001

Couldn't agree more JeevesBond!

I still haven't made anything as impressive as the layouts at csszengarden, but knowing how everything fits together... and being able to change layouts on a whim is soooooo much fun! Laughing out loud

Hmmmm... maybe it's xhtml that chicks dig... Wink

gotta finish redesigning my sites so I can show them again.

The purpose of education is... to get more jokes!

He has: 490 posts

Joined: May 2005

It gives you an excuse for those Bald spots. You can always blame them on pulling your hair out, while trying to validate your code. Smiling

JeevesBond's picture

He has: 3,956 posts

Joined: Jun 2002

As touched-on earlier, validating code isn't the only part of our reasoning. It's making the move to XML (for those who use XHTML anyway) and the act of seperating code from content, it's amazing what can be achieved with this - has anyone checked out http://www.csszengarden.com -- that's what made me switch...

It's not just a change in the way you code, it's a whole different way of thinking that encompasses the initial design right through to implementation, personally using XHTML and CSS has given Web Design a whole new meaning for me. I now find it exciting again, and using standards based code can create designs which make sloppily-coded sites look awful. Sorry - that may sound like I'm "blowing my own trumpet" honestly it's not, standards based design is the key to any successful site I've made.

Modularisation rules baby! Smiling

a Padded Cell our articles site!

Roo's picture

She has: 840 posts

Joined: Apr 1999

Quote: Most PHP and Javascript will validate, just a case of & instead of & and lower case names/values etc

Now there's something I didn't know! Good info!

Roo

They have: 39 posts

Joined: Jan 2006

Speaking of validating...how do you get gradient's to validate?
I designed wescosales.com with html and css and had my entire site validated...not an easy thing to do but so proud when i was able to show the W3Cschool validated icon. Then changed my header with a gradient and also added "trafficzap" banner and now it won't validate...any help would be extremely helpful.

WesB86

robbluther's picture

He has: 73 posts

Joined: Jan 2006

How do you get ColdFusion Code to validate?

openmind's picture

He has: 945 posts

Joined: Aug 2001

robbluther wrote: How do you get ColdFusion Code to validate?

You don't have to worry about CF as it's server side. You just need to make sure that the code it does output is valid. For example www.searchwebby is bot XHTML strict and driven by complex CF....

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

Carrie - the first thing you need to do is put that background into your CSS rather than using the table attribute. So you'd have style="background: url('images/blueheader.jpg');" or a class for that table in your mystyles.css that would include that bit. Same with the valign="top" further down that's throwing a error.

It's also throwing errors on some of your ID's - ID's should only be used for unique items. That is, things that only appear once on the page. If they're used more than once, you should use a class instead of an ID.

For the trafficzap thing, you just need to encode the ampersand in the url. SO instead of &, put &. (that's actually in Busy's post at the very top of this page!!)

Fix those things and it should validate

Rob - I don't know about CF. It's not a standard so the validator wouldn't understand it. It does handle PHP pages fine. You'd have to try it and see what happens.

They have: 39 posts

Joined: Jan 2006

thanks so much i'll get right on it..i just love having the validation code on my pages and if i do it with css it will change all at once...that will be extremely nice...i'll get back with you and thanks again

WesB86

They have: 39 posts

Joined: Jan 2006

Megan,
Thanks my site is 99% validated. By tomorrow it will be 100%...this forum is beyond awesome and so helpful.
Carrie (WesB86)
wescosales.com

She has: 31 posts

Joined: Jan 2006

A few reasons (off the top of my head) why valid code is good:

1. Your code will take up less space. Especially if you use CSS instead of style elements.

2. Your web pages will be future friendly (and easier to maintain).

3. Your web pages will be more cross-browser friendly, hence more people will be able to view your site as you intend.

4. Your web pages will be compatible with older browsers.

5. Your web pages will be more Search Engine friendly (yes, search engines DO care about valid code, most SE's see your web page just like Lynx browser which doesn't allow for any invalid HTML at all).

6. Your web pages will be able to be read by screen-readers and other disability-aimed programs and applications, hence more people will be able to view your web pages.

There are plenty more reasons, but I'm sure you can see that valid code IS important as well as moral.

Hope this answers your question =)

They have: 39 posts

Joined: Jan 2006

WEll...many thanks for all the help..my site is now 100% validated (putting the validate icon on all the pages in the next day or so) and I'll be working on the boring, conservative logo now...this forum is awesome.
Carrie (WesB86)
wescosales.com

WesB86

She has: 120 posts

Joined: Oct 2000

Nothing like ressurecting a post from 2004!!! I started reading from the beginning and lo and behold.. ran into posts from 'old timers' I haven't 'heard' from in awhile.
Funny that validation is still being questioned.
Smiling

"Nothing worth having comes without some kind of fight- 'Got to kick at the darkness 'til it bleeds daylight." - Bruce Cockburn

dk01's picture

He has: 516 posts

Joined: Mar 2002

For those people who don't want to think of it in terms of code. Think of it in terms of cars. 30 years ago cars were simple and therefore easy to fix. If something went wrong my dad could fix our car without the help of a mechanic or even a manual sometimes. Nowadays cars are so complex that only trained professionals can deal with all the electrical circuits and special features. Is this a bad thing? No, it just means the consumer demanded to have more advanced features, and for that to happen the design of cars had to become more complex. Sure my Dad can't fix the car but now he has power windows, AC, and many other features.

If you take this example of the car and translate it to the progression of coding web standards we can see great features like AJAX (controversial, I know) and XML being formed on the premise that the document they are working with is valid.

Imagine trying to roll down your power window and having it turn on the AC instead! One simple crossed wire can do that! That's why we need to demand perfection in our industry and web standards/validation are the way to do that.

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.