But it Doesn’t Validate
basix

But it Doesn’t Validate

I have a small pet peeve that I’m going to share with you. On the nights when I finish up a new CSS3 tutorial for Nettuts+ — typically while listening to my favorite Biebster songs — I click publish, and then wait to see how long it’ll take before a reader leaves a comment containing the phrase, “But it doesn’t validate.”


Thanks for the Input!

Here’s the thing about validation: it’s a tool. Nothing more; nothing less; just a tool.

So here’s the thing about validation: it’s a tool. Nothing more; nothing less; just a tool. At first glance, though, it makes sense, doesn’t it? We equate validation with best practices, much like JavaScript and JSLint. Along that line of thinking, why wouldn’t we want a perfect 100% score? Well that’s the thing: we do; however, problems ensue when the score takes precedence over our own logic.


Validating your Designs

To test your markup and style sheets, you can visit:

Alternatively, you can install the helpful Firefox add-on, Web Developer, which, among other things, offers the handy-dandy “Validate HTML” and “Validate CSS” links, as well as the option to validate even your local files.

At this point, a report will be generated, which lists any errors that the validator comes across. But herein lies the rub.

Validating HTML

Is Validation Irrelevant?

Absolutely not. I’d imagine that, particularly for those who are just breaking into this industry, the phrase, “websites don’t need to pass validation” confuses the heck out of them.

“Validation is your early-warning system about introducing bugs into your pages that can manifest in interesting and hard-to-determine ways. When a browser encounters invalid HTML, it has to take an educated guess as to what you meant to do—and different browsers can come up with different answers.”
Opera Developer Community

That said, the final score is, in fact, irrelevant.

Remember the days when we (or at least some of us) pasted those validation buttons to the footer of our websites? How funny; who were they for? The site visitors? Haha; I hope not! But here’s the thing: back then, validation wasn’t really a standard. Validate ButtonNope; in fact, if you even bothered to validate your HTML and CSS, you were a standards-embracing, cutting edge dude! Sometimes, it’s easy to forget that web standards is a relatively new concept.

Validate Before you Ask

Years ago, when I used to participate in CSS forums, it never failed: every time a new member requested help on a strange layout issue, our first response was typically something along the lines of, “Your website doesn’t validate. Fix the errors, and then come back to us if there are still issues.” Many times, odd layout issues are the result of unclosed elements, like a div. In these cases, validation can be of tremendous help.

So what changed? Is validation no longer necessary? Does HTML5 allow us to write terrible mark-up without a second thought? Is the new HTML5 doctype magic-infused? Not at all. Validation is a helpful tool that allows us to pinpoint missed closed tags, extra semicolons, etc. That said, the final score is, in fact, irrelevant. It’s not a magic number – that, at 100%, contacts The Architect behind the scenes, and instructs him to apply bonus points to your website. This score serves no higher purpose than to provide you with feedback. It neither contributes to accessibility, nor points out best-practices. In fact, the validator can be misleading, as it signals errors that aren’t errors, by any stretch of the imagination. The HTML4 validator has quickly become out-dated, but luckily the W3C has a new HTML5 validator (still experimental) that’s much improved.

Now, keep in mind that well-formed markup can boost SEO; however, there’s no specific correlation between SEO and a validation score.

HTML5 standardizes many of the features that some browsers have supported for years, such as custom attributes (via the data- prefix), and ARIA attributes, which fail the W3C’s HTML4 validator.

When testing new designs, be sure to check the experimental HTML5 validator option. With this option set, you can use the supported CSS3 properties, custom data- attributes, and more.

Validator Options

How About 75% or Higher?

Never, ever, ever compromise the use of the latest CSS3 techniques and selectors for the sake of validation.

What if we strive for at least a 75% score? I understand the thinking, as I thought that way too at one point; though, again, it’s irrelevant. When validating, your primary focus should be on determining where you’ve made mistakes. Validation isn’t a game, and, while it might be fun to test your skills to determine how high you can get your score, always keep in mind: it doesn’t matter. And never, ever, ever compromise the use of the latest doctype, CSS3 techniques and selectors for the sake of validation.

The dirty secret of browsers is that they never perform HTML validation against a DTD. The doctype you put at the top of the document switches the parser into a particular mode of operation, but no operations involve downloading the doctype and verifying that the code matches. What does this mean? It means that a basic syntax parser handles HTML, with exceptions specified for self-closing tags and block vs. inline elements (and I’m sure other situations as well).
Nicholas Zakas


What Doesn’t Validate

Dependent upon the options you specify before checking your designs (HTML4 vs. HTML5), the validator will scream like a baby when it comes across:

  • Browser hacks
  • Vendor-prefixes
  • Custom attributes
  • Genuine errors, such as unclosed elements
  • ARIA roles

Ahh, browser hacks… should you use them? The answer to that question has been debated to death, and it certainly exceeds the scope of this tutorial; however, keep in mind that, for instance, usage of the IE6-underscore-hack will fail validation.

For this reason, many designers prefer to use non-breaking techniques instead.

So:

/* Fails validation */
#myElement {
  _position: relative; /* targets only IE6 */
}

Becomes:

/* Passes validation */
* html #myElement {
   position: relative; /* targets IE6 */
}

The reason behind this line of thinking is, what if, in the future, say, Internet Explorer 10 will also render properties that are prefixed with an underscore? In cases such as that, your IE6-only (so you thought) styling will also be applied to IE10 and beyond, presumably. Now, the truth of the matter is that this would never happen, as it’d break a large number of websites. That said, this method of browser-targeting is indeed a hack. Except in smaller or rare cases, it’s better to use a conditional stylesheet, or a form of feature detection to target specific browsers.

Vendor Prefixes

While we can all agree that applying multiple vendor prefixes to properties, all for the sake of achieving, say, rounded corners, is incredibly tedious, you should thank your lucky stars that the browser vendors experimented with these technologies before they were officially recommended.

Had webkit not experimented with CSS gradients, and had Mozilla not improved upon their suggested syntax, gradients would not be as widely supported in the current generation of modern browsers as they are today. You see, browsers have a huge hand in shaping the future of the web.

.box {
  background: #666;
  background: -moz-linear-gradient(top, black, white);
  background: - webkit-gradient(linear, left top, left bottom, from(black), to(white));
  background: linear-gradient(top, black, white);
}   

With all that said, the use of these vendor prefixes will cause your style sheets to fail validation. But that’s okay; don’t let that worry you one bit.

Learn the rules so you know how to break them properly.

Unfortunately, even now, many designers elect to use, in our example above, images to create gradients — if only for the purpose of pushing their validation score back to 100%. If you fall into this camp: you’re doing it wrong.


Use Validation…

  • To test for unclosed HTML elements
  • To check for typos
  • To ensure that you haven’t omitted any semicolons
  • For peace of mind

  • Validation is Not…

    • A game. Don’t waste time achieving a 100% score, when you know exactly what you’re doing. However, do use it to point out your mistakes.
    • An all-encompassing checker. While it does test for errors, it does not point out bad practices, accessibility issues, etc.
    • To be used as an excuse for not embracing the latest CSS3 techniques. The longer you say to yourself, “I’ll use this in a few years…” the further you’ll fall behind.

    Conclusion

    If you only take one thing from this article, remember that validation is simply a tool. As soon as you compromise your own logic and techniques for the sake of appeasing a validator and achieving a meaningless score, it ceases to be a tool. That said, use it, and use it often!

Tags: basix
Note: Want to add some source code? Type <pre><code> before it and </code></pre> after it. Find out more
  • http://www.josephvillajin.com Joseph Villajin

    I agree 100%. While taking multimedia and web classes, my “old-school” professors were constantly docking points if our projects were not 100% valid. I explained that certain things just have the be the way they are so the website will function properly, but sadly it was having a nice website or changing it up to get an ‘A’!

    • Jeffrey Way

      I suppose it depends on whether or not your teacher was checking to see what exactly was failing.

      • Crazy2death

        Excellent article, But… Do you really listen to Justin Beiber ? if so, i wanna tell you sir that you raped the image of the demigod i always pictured you.

      • http://www.jeffrey-way.com Jeffrey Way
        Author

        No – I do not.

      • http://www.jeffrey-way.com Jeffrey Way
        Author

        It’s a long running joke.

      • http://prop-14.com Randy

        So glad to hear this is just a joke! As a long time musician it was like hearing your most respected coder just went back to using Front Page.

        I agree 100% with this article. If you have ever tried explaining to someone that their site validates while they have stacks of paper to get through on their desk, they don’t really give a sh**. “Just make it work!”. They say.

      • w1sh

        What’s wrong with the Biebster? Y’all some haterz.

      • http://www.josephvillajin.com Joseph Villajin

        I wish that were the case. It was more along the lines of all successful websites need to pass all validation, or else it should not go live.

        But this article is a great explanation to why there are validation services in the first place.

  • http://www.imawebdesigner.com Luke Desroches

    Web developers shouldn’t need a validator to tell them what good code is. They should know the difference between ‘poorly written code’ and ‘well written code that contains vendor-specific prefixes’. If they don’t, they are morons.

    • http://www.itontheweb.co.nz David

      Or maybe they are just newbies that need some guidance…….If it is highlighted to someone what is not valid, then they have the opportunity to find out the ‘WHY’ and decide if it’s important. By having validators it gives a standard reference point from where to go. Just because I haven’t yet learnt to spot well written code instantly doesn’t make me a moron….just someone who is learning what they need to learn…

      • http://www.jeffrey-way.com Jeffrey Way
        Author

        Which is why I make reference, in multiple locations, that validation is a very good thing. :)

      • http://www.jeffrey-way.com Jeffrey Way
        Author

        Oh sorry, David. I responded to your comment from the WP Admin panel, and thought you were responding to me specifically. Disregard. :)

    • http://www.wdonline.com/ Jeremy McPeak

      By that logic, any a compiler or runtime shouldn’t check code before its executed. The same could be applied to debugging tools; we should write flawless code 100% of the time.

      HTML is easy, granted, but it’s just like any other language. If a human is involved, there is a chance something will go wrong. When wrong happens, a tool to spot issues is easier and faster than going through a file line by line.

    • Human

      I thought we are all human. Occasionally, mistakes creep in.

  • Mark Sinkinson

    Great article!

    Browsers didn’t just have a ‘huge hand’ in the shaping of the web, there would not be an HTML5 without the work done by the browser developers

  • Nate

    Thank you. Validation nazi’s piss me off.

    • Chris

      I’m a validation nazi! No fair! I think most people don’t validate when they should and then use it as an excuse not to embrace the latest technology.

      • Nate

        LOL Sorry to offend :)

        You have a good point tho. I agree with that.

    • http://creditorwatch.com.au Dale Hurley

      I think the point of this article is to say that validation has a place though is not the be all and end all. Validation Nazis are just trying to adjust to a new world in which XHTML has had its day (which I don’t think anyone actually followed it exactly as IE 5 and I think 6 would display it as XML).

      Validation is extremely important to make sure your HTML is well formed which will help eliminate those strange things that happen in different browsers. I think it is more important to learn what what the fails mean. For instance it helps in usability to wrap a div in an anchor tag if it is logical that the whole section should be a link. With touch devices, even more so.

      Though some do try to make it so, using excuses of accessibility. For instance the http://mcfarlaneprize.com/ immediately eliminates entrants based on validation. So if you use the Google Chorme Frame /*ping*/ you are gone.

      I think if you are learning web dev (yawn) it is important to get prefect validation. Once you understand the rules then break them.

      Ultimately even if it validates you still need to test in all of the current day browsers, including IE6, I have a lot more users who use IE6 then screen readers, however Google code has a cool IE.js which fixes 97% of the IE6 crap.

  • Chris

    Preach! 100% agree. I think people should be using the latest techniques and know what they are doing when they “break” something.

  • Conor Haining

    Found this Very Interesting, Im new to web Developing and always get annoyed when I use a Validator because it Is never 100%.

    • http://toolnames.com Dale Hurley

      Do you understand why it is not validating?

      I would not use this article as an excuse not to validate you code. If you are new you should try to get 100% validation, and only get less then that if you 100% understand why it is not validating. As I said above it is more important to understand the rules you breaking. You should not just breaking them because you don’t know what you are doing wrong.

  • http://www.arvag.net GaVrA

    Great article! I agree on every point, especially with this :)

    “if you even bothered to validate your HTML and CSS, you were a standards-embracing, cutting edge dude!”

  • Tyler Cook

    But it doesn’t Validate, Sorry I had too! Great article mate and all too true.

  • http://www.jeffadams.co.uk Jeff Adams

    Really, REALLY good article – something I’ve been wanting to say for ages and ages.

    As an author over at Themeforest, sure it’s annoying that some bits of CSS won’t validate adn at first I was a bit wary of uploading a file.

    But all it really needed as note to the reviewers saying why e.g. browser-specific css etc. and it’s fine.

    Validation is really, really handy once you’ve finished coding to fix things like images without alt tags – and not because I care about alt tags for accessibility (I know I should) but because alt tags are an excellent form of SEO as well!!

    Thanks for this article, it’s nice not to feel alone on this. IT’S A TOOL!!!!

  • http://www.wdonline.com/ Jeremy McPeak

    Hear hear!

  • http://www.sz-media.org Nico Poggenburg

    hmmm, isnt a valid page the best? i mean there are rules and we should stay valid with them. the css hacks and all the other nice things are some kind of art in my eyes. great to have and use them BUT there can be much trouble with newer or older technology. follow the standards is a save way to make something accessible for everyone.

    • http://creditorwatch.com.au Dale Hurley

      http://dev.w3.org/html5/spec/Overview.html – Hmmm?!?!?! Sometimes validation is not everything.

      A valid page is best compared to a poorly formed page, e.g. tags not closed, alt attributes not used.

      However there is some things that are not valid though are better than a valid page, like the Google Chrome Frame.

  • http://www.weingage.com/ Jay Hughes

    Validation is one of the things I’ve been wondering about. I’ve tried to validate some sites but seen some errors that seemed like they were a little unfair (like vendor prefixes for rounded corners, etc). It’s good to see someone give some guidelines for what to use validation for. Thanks – Great article!

  • http://www.creativeweb-design.com Derek

    I always try to validate my code (well HTML at least) I had it plugged in my head it may give that extra helping hand in SEO but I agree what a pain!

  • http://www.ferdychristant.com Ferdy

    You just make all of this up to not have to validate your own sites.

    j/k ;)

  • http://www.envisionedprototype.com/blog/ Daniel Yearwood

    I have to disagree some with this post. This is just my opinion, to each his own, but it looks like the items that are discussed seem to be targeted towards browser-specific hacks or experimental code. You can use CSS Conditional statements to tell the browser to reference a specific style sheet you use for hacks. I never include hacks in my main CSS document, especially when they are browser specific, for the simple fact that I know that they won’t validate. Put all your standards-compliant CSS in a main style sheet, hacks should be targeted using CSS conditional statements if needed.

    The other thing I think this post missed that I think is a key point, is that the purpose of standards compliance is that if every browser where rendering pages the way they were supposed to, you wouldn’t have to use the hacks and cheats and proprietary code to make things work. That’s why we should strive for compliance. Things should work the way the way they were intended to, and that should be universal.

    I know there are times when standards compliance just seems impossible (and sometimes it just is), but I think as designers we should always strive with that goal in mind. Sometimes it just takes a little creative thinking to achieve what you want.

    • Chris Sanders

      I actually think validation is used as the easy way out for people who wrote HTML documents that really aren’t very good even if they do validate. While I think standards should always be the goal, in the case of emerging standards I believe a pass should be given. Standards don’t become standards on the web until people use them and browser vendors use them. I don’t necessarily think additional http requests is the way to go either if you can avoid them.

      • Chris Sanders

        Ohh and for the record I can get my code to validate or very close on the first try. So I mostly think people who are complaining are just being lazy and this gives them some license not to validate their code properly. The reason I say that is because I know people much smarter than me who can’t get their stuff to validate and then when I dig deeper it’s because they just wrote horrible code.

    • Ron Derksen

      So what is the exact way things are intended to work? Even with the W3C recommendations, there’s still a lot of room for different interpretations of those recommendations and that is where most of the differences between browsers come from.

      That said, I think having your hacks in a separate stylesheet or inside your main stylesheet doesn’t really differ much. Conditional comments are just as big of a hack as CSS hacks, imo. So whichever you use is down to preference.

      And as Jeffrey states, aiming for 100% validation keeps you away from using CSS3 attributes which are at the moment implemented with vendor-specific tags. In my opinion, that’s a big pro for passing up 100% validation.

  • Bruno

    But it doesn’t validate!

    • Bruno

      Kiddin’
      I just had to do it. :)

  • http://andrewsmith.comxa.com/ Andrew Smith

    I really only use validation as a small error-checker. I am always tinkering with my code to create the most semantic and usable markup, and if something I do makes the code more semantic or usable, I will not lose sleep if it makes it invalid.

  • Troy

    I ran the test on this page out of curiosity. 51 errors html, 60 css. :O

  • http://www.ajvweb.fi Aapo

    Thank you x 1000, those 100% validation nazis really are a pain in the ass.

    • http://creditorwatch.com.au Dale Hurley

      Aapo – your code should still be good.

  • Dan LaManna
  • ElSherbiny

    Awesome article :)

    may i ask one thing from you “Jeffrey”

    just i want you to put article about validate inputs in PHP and how to prevent my script from sql injection

    and what’s useful functions which i should use in my script

    and thanks in advance.

  • Yannick Stahl
    • http://www.jeffrey-way.com Jeffrey Way
      Author

      How odd. No doctype? Wonder what the reason is for that. I’m sure there is one…

      • http://portfolio.michaeladamek.com/ Michael

        Looks like they added a Doctype! And now pulling less erros…. Yay Amazon.

  • http://www.purplecoffee.co.uk Gareth Evans

    I completely agree with this post. Validation is never going to be 100% correct for you when you’re working with the newest technologies. Where it is good is with something like the following;

    2476 .facebook_site .activetuts Property background-positio doesn’t exist : -150px 0 -150px 0

    Jeff, may want to fix that typo ;)

  • Batfan

    I agree with you here. Too much emphasis is placed on validation.

    However, in the case of the given example of a “CSS3 article”, I am far more concerned with browser compatibility.

  • Miguel

    Hey!

    This site don´t VALIDATE!

    http://tinyurl.com/34d9hmv

  • Werner

    Hm…but my brain doesn’t validate…sometimes…=)

    100% /sign

  • James

    As I would normally agree on all your terms, this time i`m not!

    Yes i agree validation is just a tool, you should check it out only if something doesn`t feel right, as a fast way to discover any errors.

    I even agree on embracing CSS3! I for one use it all the time, however (!!!!) I always make sure it has a nice degradation to fall back to. Having said this, what I mean is, always make sure that older browsers ( even FF2 -> FF3.0 ) to support gradients, rounded corners etc.

    This might seem silly, why bother targeting older browsers too? Well for one, we should be damn happy they even upgraded to Firefox or Safari or Chrome, even IE8 for that matter! Breaking websites or showing boxes without any proper visual styling isn`t rewarding. Hence always have a fallback for your site.

    That`s all

    • http://www.jeffrey-way.com Jeffrey Way
      Author

      James – that doesn’t really have anything to do with validation. Fallbacks are unrelated.

      The problem is that it’s virtually impossible to provide an identical experience across all browsers. At some level, there’s going to be inconsistency. It’s simply a matter of deciding where that line is. Do you really care if IE users don’t see 3px worth of rounded corners?

  • James

    Not to sound pedantic but perhaps “For piece of mind” should be “For peace of mind”? :)

    Great article and I remember a long-winded rage post on your blog about a certain visitor X who e-mailed you complaining about how you can encourage validation when your own website didn’t validate 100%!

    Glad to see you’re travelling further than your blog, Jeffrey!

    • James

      Woops, just for clarification I’m not the James who posted above Jeffrey!

  • http://ideasandpixels.com Allen Gingrich

    It’s simple: use W3C validation if you’re a beginner just learning the ropes. Once you become familiar, which shouldn’t take any time at all, you provide your own validation.

    It’s like that old adage: you should only break the rules once you know the rules.

  • http://azzcatdesign.com/blog Catherine Azzarello

    lol! I just HAD to scroll down to comments b/f reading article to see if you’d get more flak for the Bieber comment or about validation. ;-)

    • http://www.jeffrey-way.com Jeffrey Way
      Author

      haha – I think people have finally realized that I’m just teasing with the constant Justin Bieber references.

      • http://toolnames.com Dale Hurley

        I think the Biebs references are awesome!

  • http://connorcrosby.me Connor Crosby

    Excellent article! There are things on my site that are “errors” but I leave them be because they are minor and also my website works fine. I don’t care if my sites aren’t 100% valid.

  • http://www.hangaroundtheweb.com rajasegar

    Great article, i am too lazy to to validate , oops

  • http://twitter.com/gemmaweirs Gemma

    No excuses for not getting your code to validate. I know for a fact that CSS3 will validate, but using vendor-specific CSS3 will not. So put them in a separate stylesheet. Hacks also should be put in a separate stylesheet. If your markup/CSS is experimental then I guess it’s an exception but for the most part there is no reason not to get your page to validate.

    I always make sure my markup and main stylesheet validates 100%. I still produce nice, attractive work that is usable and accessible.

    • Mike Hopley

      What is the benefit of putting your hacks and vendor-specific extensions in a separate stylesheet? Do you feel a sense of purity, of cleanliness? Or can you cite a more objective benefit?

      To me, hiding your hacks away in separate stylesheets is a form of vanity. You’re trying to pretend that your code is beautiful and pure, when actually it’s no less ugly than the same code in one stylesheet. The price of this coding vanity is an unnecessary HTTP request; the reward is the self-righteousness endowed by a (fake) 100% validator score.

      It’s often said that CSS hacks should be avoided because they may break future browsers. For the _property and *property hacks at least, this is far-fetched reasoning. It’s extremely unlikely to happen, as Jeffrey said in the article.

      I can only wonder, Jeffrey, why you don’t make the logical conclusion: these hacks are fine, and it’s better to use them than to incur unnecessary HTTP requests. They also let you keep related code (e.g. for a module) in one place, rather than spreading it out across a “main” and “hacks” stylesheets. This is much better for maintenance.

      Incidentally, Yahoo uses and recommends the _property and *property hacks for targeting IE6 and IE7, for the reasons I just gave.

      • http://www.jeffrey-way.com Jeffrey Way
        Author

        Hey Mike –

        Truthfully, I’m okay with them. For things like fixing the IE double-margin bug, I think it makes perfect sense to add that extra IE6 rule in my main stylesheet.

        But, for larger edits — like a fairly different layout for old IE users, I’d prefer a conditional stylesheet.

      • Mike Hopley

        That sounds sensible to me, Jeffrey. :)

        I can see how a separate stylesheet would make sense if you’re creating significantly different designs for IE.

        I would normally give IE the same essential design, but with some bells & whistles disabled and some hacks to fix basic layout. For that reason, I would normally keep everything in one stylesheet.

  • http://www.bigdotmedia.co.uk Steve McGrath

    Realy good article, however on the issue of background gradients, I still use images, not to push my validation score, but to ensure all browsers have a similar experience on the website.

    We are a commercial web dev company and we do not have the luxury of being able to use browser specific enhancing technology. It is more important that all browsers have a similar experience.

    We are trying to integrate some graceful degradation but even then, we still need to give our clients (a frightening number of them still on IE6) a similar experience.

    We dont however treat validation as the panacea of all our problems.

    • http://www.jeffrey-way.com Jeffrey Way
      Author

      If older browsers must have the same gradient, why not use a service, like Paul’s Modernizr to use native CSS gradients in the browsers that support it, and then a fallback image for older browsers?

  • Eduardo Barros

    Google doesn’t validate: http://validator.w3.org/check?uri=http://www.google.com&charset=(detect+automatically)&doctype=Inline&group=0. Yup, 35 errors from one of the top 5 websites from the world.

    Facebook doesn’t validate: http://validator.w3.org/check?uri=http://www.facebook.com/&charset=(detect+automatically)&doctype=Inline&group=0&user-agent=W3C_Validator/1.1 . Yup, 12 errors from the most visited website on the world.

    Silly, no?

  • http://www.webnt.cz Bronislav Klučka

    1/ Vendor prefixes in CSS will never validate, it’s purpose, yet they are recommended by W3C
    http://www.w3.org/TR/css3-syntax/#vendor-specific
    so no wrong doing in using them
    2/ CSS is in much more experimental state in browser than HTML when it comes for syntax, so I wouldn’t mind much for CSS validation
    3/ there is no reason to have HTML invalid (with exception for embed element for legacy browsers and plugins and 3rd party mashup), purposely invalid HTML means bad coder, nothing else. It’s just nonsense to use unknown element and with HTML5 you can have custom attributes.

  • Alberto

    I hate vendor prefixes! Couldn’t they just use standard W3C definition?

  • Len

    AA validation is a business requirement for our website. I keep asking them why and they don’t know, they just don’t know.

  • http://twitter.com/ZoranJambor Zoran Jambor

    It seems to me that far to many people view this as black or white. They must always validate, no matter what, or they just don’t care about validation. I think validation is important when you’re just starting up, but becomes less relevant as you gain more knowledge.

    Validation is a tool, as you brilliantly said, and if you look at it from this perspective, it can offer quite a lot. It has saved me countless hours of debugging or finding minor markup issues. But I’m not breaking my head if W3C validator says that I have a couple of errors in markup, because I know that these are vendor prefixes, CSS3 enchantments, HTML5 elements, or something like this. Custom font by using font-face far outweighs a couple of W3C errors, in my opinion.

    And on the side note, I just don’t understand people that don’t like the Biebster (or don’t understand your jokes). The Biebster puts a lifetime of experience into his songs and we should all worship him. Also, he does validate (100%) and he is cutting edge, so… beat that, developers. ;)

  • http://uklwd.net/ Kane

    I validate, but common sense should prevail over validation. Some people get so obssessed with validation they lose the purpose of the tool.

    Great post.

  • http://paulirish.com Paul Irish

    It’s also worth noting that the way browsers parse your HTML has nothing to do with how the validator feels about it. So better validation scores don’t mean things will look more consistent cross-browser.

    In fact, the W3C is looking for help with their HTML and CSS Validators.. for example. they are accepting patches that will downgrade the error thrown on css vendor prefixes to a warning. :)
    Visit my lazyweb requests repo for more info: http://github.com/paulirish/lazyweb-requests/issues

  • Sam Sherwood

    I’d say there are many more arguments against vendor-specific CSS than just getting your code to validate… Validation points out possible caveats in your code, in the same way that ground surveying points out possible issues in a foundation. Should you do it? Yes. Can you get away with fudging? If you know what you’re doing.

    When you’re working in a team larger than, say, one, there are benefits to providing a standard, valid set of code — not only in the short term, but over the course of a site’s life, as well. This doesn’t make it a hard and fast rule, but certainly a guide.

    • Mike Hopley

      I’m not convinced by that argument.

      Would a team of 700+ front-end engineers be large enough for you? Because that’s what Yahoo has, and they are using vendor-specific CSS.

      If you write your CSS in sensible modules, it’s not difficult to maintain the vendor-specific stuff. Better yet, use a CSS preprocessor, or just run your CSS through PHP first. Then you can output the vendor-specific stuff via functions. As CSS support evolves, you can change one function and have all your CSS update itself.

      Your CSS code with embedded PHP:

      .rounded-box {
      round(3) ?>
      }

      Output stylesheet code:

      .rounded-box {
      -webkit-border-radius: 3px;
      -moz-border-radius: 3px;
      border-radius: 3px;
      }

  • http://blogjunkie.net David

    Thanks for this article! It’s a pet peeve of mine too and I’m glad that there are others who feel the same way. Validation = training wheels

  • http://www.pelicansareevil.com Ben

    A simple workaround to the ie specific css

    <!– paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ –>
    <!–[if lt IE 7 ]> <html lang=”en” class=”no-js ie6 ie”> <![endif]–>
    <!–[if IE 7 ]> <html lang=”en” class=”no-js ie7 ie”> <![endif]–>
    <!–[if IE 8 ]> <html lang=”en” class=”no-js ie8 ie”> <![endif]–>
    <!–[if IE 9 ]> <html lang=”en” class=”no-js ie9 ie”> <![endif]–>
    <!–[if (gt IE 9)|!(IE)]><!–> <html lang=”en” class=”no-js”> <!–<![endif]–>

    Then you can simply use

    .ie6 .my-selector {
    }

    • Mike Hopley

      That’s a neat trick, but it has a downside:

      .selector {…}
      .ie6 .selector {…}

      Notice that the IE6 override has a longer selector chain. Longer chains have higher specificity and override shorter ones.

      If you’re writing CSS in reusable modules (and you should be!), this is a problem. See this video at around 21 minutes in:

      http://www.youtube.com/watch?v=j6sAm7CLoCQ

      • http://anthonymclin.com Anthony McLin

        Actually Mike, the higher specificity is exactly the point. The conditionals ensure that the body has the IE6 class, but only for IE6 users. Then, the extra specificity ensures that IE6 uses the right styles, instead of relying on hacks that use CSS-parsing problems.

        Take a look at the HTML5 boilerplate that’s been reviewed so frequently here on netTuts. This is the exact same technique used there.

      • Mike Hopley

        I understand the technique just fine, thanks, and I’m aware of its use in HTML5 boilerplate.

        I dislike the technique because it creates specificity differences, which make it harder to write CSS in reusable modules.

        Almost no CSS is written in reusable modules, so I’m sure the technique fits well with most existing CSS. But if you want to follow Nicole Sullivan’s “OOCSS” approach, then it’s a bad way to deliver your IE hacks.

        The *property and _property hacks are quite safe. By using these, I can keep my specificity “flatter”.

        I do think the body-class approach is an improvement on IE-only stylesheets. For the type of CSS that I like to write, however, CSS hacks are the best option. For the type of CSS that you like to write, maybe not.

  • arnold

    I think validation is important but website doesnt need to be 100% validate,

    I didnt know that there’s no correlation between SEO and a validation score.
    I sometimes heard that from other blogs, they say it boost SEO

    Thanks for the post JW

  • http://brianswebdesign.com Brian Temecula

    I used to go crazy with validation, but then I put adsense ads on my website. Somebody needs to tell Google that their code should validate!

  • Vic

    Eh… As long as your code validates properly it doesn’t matter if the 3rd party elements don’t… I personally am quite strict about the code I validate – until I see the green banner I hack away all the issues.

  • http://www.giulianoliker.com Giuliano

    This page doesn’t validate. Thus, I render this article incorrect. Please go back, rewrite and this time use Miley Cyrus as inspiration, she validates.

    All hail W3C Validator!!!

  • Sara

    What annoys me is when clients hear about “validation” and cling to it like some magical indicator that a site is high quality. They will accept ugly design but insist that a site validates… well, not everyone, but close. And while I’m thinking about excuses not to use CSS3, my biggest one is definitely not validation. Actually, I want to use CSS3, but clients ask for pixel-perfect in all browsers, even IE 6. Again, I think they’re just clinging to something that sounds good to them, but it’s such a pain.

    • http://www.christopherleedesign.com Chris

      I completely agree! There are also a number of “talent agencies” or more commonly referred to as recruiters who will visit a potential freelancers portfolio, run the validator and if it returns an error they simple move onto the next freelancer without even understanding what the error was. The sad reality is that as web designers and developers we are always in tune with changes in the industry and always embracing new technology whereas; folks who are not actual designers or developers don’t always understand the new technologies and use validation as a way of “filtering” people out and can often times walk right past high quality freelancers based simply on the validator.

      The validator is a great reference point and tool in debugging and writing clean mark up for designers and developers, but when left in the hands of the general population it can be a real menace.

  • http://www.creativity-quotes.com Colin the Creative

    I had come to this exact same conclusion a little while ago, however its always good to see arguments enumerated explicitly rather than just feeling they were true. So thanks for taking the time to post out the rational explanations of it all, it’s helped to clarify/solidify some of it all into thoughts. Colin.