Document types and validation?

It doesn't matter if you do all the error checking in the world, or if you have the most beautiful graphics, if your site or application design isn't usable, it's not going to do well. Get input and advice on usability and user interface issues here.

Moderator: General Moderators

Post Reply
User avatar
Sindarin
Forum Regular
Posts: 521
Joined: Tue Sep 25, 2007 8:36 am
Location: Greece

Document types and validation?

Post by Sindarin »

Well I've seen lately a rage to create pages with valid html, css etc. and usage of document types (strict/transitional). My questions are, what is the use of document types?
I've used them a bit and saw minor changes in my design, but apart from that I can't understand what might be great about them, and secondly about html,css validation, everyone's adding "Valid HTML!", "Valid CSS!" tags on their website, but why the user should be concerned? Does it have any significant impact on how the page is displayed?
I've tried to Google for reasons why I should be using doctypes and having valid html, but the one I came up with is that "you should do it".
User avatar
shiznatix
DevNet Master
Posts: 2745
Joined: Tue Dec 28, 2004 5:57 pm
Location: Tallinn, Estonia
Contact:

Post by shiznatix »

It makes the browsers job a heck of a lot easier if everything is valid. If it is valid, your page will render the same across all browsers that adhere to standards (basically all but IE). So really, code to standards and it will make your users expierence better with a faster page load and it won't matter what browser they are using. Also, this will make it easier for any developer to be able to edit your page without breaking it, even if the developer is still you. If you just use tag soup without caring about standards, you will hate yourself when you have to go back and edit it and you also won't be able to advance since you will be stuck in "your way" while the standards say that it is now going to happen another way.

As for the IE flaws, do everything correct to standards then check it in IE. If IE decides to be silly, google for the problem or ask here and there is almost always a work-around that will still let your pages validate 100%.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Future compatibility with browsers.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Post by matthijs »

We do it so we can place those cool badges on our sites :)

(just kidding, there was a time it was cool, but not anymore)
User avatar
Inkyskin
Forum Contributor
Posts: 282
Joined: Mon Nov 19, 2007 10:15 am
Location: UK

Post by Inkyskin »

There are other reasons too - if someone is using a screenreader for example, valid code will make it much easier for the software to read the page, and find details for elements, such as alt tags for images etc. It can also help on an SEO front - having the orrect tags, markup etc can help spiders determine what information you have to offer more easily.
User avatar
Sindarin
Forum Regular
Posts: 521
Joined: Tue Sep 25, 2007 8:36 am
Location: Greece

Re: Document types and validation?

Post by Sindarin »

I see now, however is very hard to create a valid & truly functional page. Take for example the ie6 png hack, for the sake of one browser the page does not validate. Well, it figures when Microsoft's site has already numerous validation errors. :D
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Re: Document types and validation?

Post by matthijs »

I don't think creating valid pages is hard. The validation tool tells you exactly what the errors are and how to solve them.

If you are concerned with hacks making your code invalid (like the png hack), you can use conditional comments and place all invalid stuff in a IE specific stylesheet. If that doesn't validate, well, blame Microsoft.

Remember, validating a site is not a goal. At least not for me. It is a means. Validating is a very useful tool to help you write good code. Code which you can trust, that it will work in modern and future browsers and devices. that's all.

It's the same as having strict error reporting on. Each warning or notice tells you something is wrong or might cause problems.
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Re: Document types and validation?

Post by Ambush Commander »

Semantic markup, IMO, is far more important.

Oh, and the buttons are absolute bosh.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Re: Document types and validation?

Post by pickle »

DOCTYPEs tell the browser what kind of document it's displaying. Without a declared document type, browsers usually render a page in "quirks mode", which is basically a bunch of hacked rules thrown together to try & get all pages to display somewhat properly. With a declared DOCTYPE, most browsers render a page in "standards mode" which is a more standards-compliant mode. The different rendering engines are what cause the slight change in appearance.

For me, there are 3 reasons for making a page validate:
  1. Having standard code makes all pages much easier to read source code-wise - there's no special cases or tricks & everything is in plain sight.
  2. Valid code is a sort of baseline that all browsers should know how to handle. If the code is not valid & is tweaked for a particular browser, then all users without that particular browser will likely show a more messed up page than if the page validated.
  3. Its a badge of professional honour to say I build valid pages. Anyone can throw together a webpage - that's what Frontpage was made for. It takes someone who is at least somewhat skilled in their craft to make a valid page.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
Inkyskin
Forum Contributor
Posts: 282
Joined: Mon Nov 19, 2007 10:15 am
Location: UK

Re: Document types and validation?

Post by Inkyskin »

The way I look at it is this: If you were to build a house, and ignore law on the way it should be built, it'll likely break apart and fall to peices. If you follow regulations, it'll most likely stand up for a long long time.

Whats the point in programming if your not going to do it properly? If your not doing it to a standard, your not really programming at all, your just hacking together scrappy code.

Admittedly none of your visitors know what valid html is, but when they see things like "Coded in valid xhtml", they at least know that it's conforming to standards, and that who ever built it has taken pride in thier work.
Post Reply