WordPress & Valid Code

Hi there,

So in the last little while every time I run website coders’ sites through the CSS & (x)html validator, they of course come up with a lot of errors & they are telling me a WP site can never be valid b/c of the plugins & theme.

Is this true?

Thanks

Michelle

I would say that it is very difficult but not impossible.

Be sure to differentiate between Warnings and Errors

Anything can be validated if you put the effort in. However, it 100% is not worth your time. Make sure it’s working in all browsers but I wouldn’t bend your back over this.

Actually, the only way you could validate your WordPress site if you have plugins or a theme that are the issue is to possibly modify the code of the plugins or theme which is a bad idea, because those modifications will be overwritten when you update the plugin (and you don’t want to ignore updates for security reasons). So no, I don’t think you would be able to properly validate the site.

1 Like

Validation is over-rated. First off, if you use anything requiring browser prefixes (like flex layouts in Safari) you’ll fail CSS validation and get errors in the console of browsers that don’t support the prefix.

Second, XHTML is a myth, was never supported by IE, and is invalid code if transmitted under the text/html header to trick IE into using it, and using true XHTML kills pretty much every javascript framework because XHTML documents do not have an innerHMTL attribute, and that’s what jQuery and the like use to perform much of their validation. Also the /> closing such as in the
tag is required XTHML, but invalid HTML.

Third, Validators check for the current code you are supposed to use, they throw errors and warnings anytime you use legacy attributes which are sometimes required to get IE 8 into gear.

So don’t sweat validation too much. Your code needs to be valid enough to keep the browsers out there out of their respective quirks modes (although most browsers no longer have such modes - IE being the big exception) and that’s it. Keep in mind that major web publishers don’t care. Look at the raw source code of www.google.com sometime - they don’t even bother to transmit the ending because all the browsers out there will figure that out on their own, and it saves them transmission bandwidth.

IE9+ support it. Once IE8 dies then XHTML5 pages will be perfectly practical. They haven’t just released a new version of XHTML for nothing - this time since all of the browsers that support HTML5 will also support XHTML5 people will be able to use it just as soon as IE8 dies.

Mittineague - how do I tell the difference?

Ok, so this doesn’t help me unfortunately. I need to find a quick way to see if the coder’s sites are crap or coded well.

I’m not about to open 20 potential coders 5-10 sample sites in all 5 browsers just to test it. That’s just too much work.

Michael you didn’t read my post correctly. I’m NOT a coder, I’m an entrepreneur & I teach my clients how to find a good coder, so I need to know this for myself & to help others…

Forget about the x part then, so there’s no way to test a WP site to see if it is coded well b/c of the plugins?

Why can’t the validator just read the actual CSS & html code & skip the plugin part?

And CSS code is also affected by the plugins? I guess yes, it’s affected by the theme.

Thanks guys

The validator is reading the CSS and HTML. Plugins generate their own. In some cases they might not output the best quality HTML/CSS (it can be hard to alter the HTML they output without editing the plugin code directly which could lead to issues when the plugin is updated). This could trigger errors/validation warnings. While validation is important. You can’t really go by this to say if a WP theme is coded well or not. I mean it could tell you that there are issues, but if the site still works in all browsers then I wouldn’t fret about a couple of errors/warnings. :smile:

Ermm, By how the validator calls them as Warnings or Errors

If it’s too much, then don’t, easy peasy.

You’ll find that many errors are compounded upon each other. Fixing one error could potentially solve many. It may not be that much work.

Unfortunately, being able to pass validation has little to do with whether the code is well written beyond correlation that is valid output and good code tend to go hand in hand.

No - the validator can only read the outputted HTML & CSS. It can’t see the underlying PHP.

This really isn’t any different from any other professional field. Check prior work and references.

Right, so if there’s a correlation, then, than it’s safe to assume that if the code doesn’t validate (especially if I state I want valid code in my hiring ad) then they don’t know what they are doing.

And I wasn’t asking for PHP code, just the html/CSS. I understand WP needs PHP code written the odd time, but most of the time it’s just html/CSS.

I’ll disagree with your last sentence. Many companies both on & offline hire terrible coders. They wouldn’t know a great coder if he slapped them in the face, so while yes, references matter, overall I don’t trust others to tell me whether someone is good in the IT industry unless I get several other coders who aren’t friends of the one coder saying their code looks pretty good. I once lost a whole HD b/c someone recommended his geek to fix my computer.

The problem is your trying to appraise whether the code is sound by analyzing its output. That’s akin to judging a book by its cover. I’ve seen crap code create valid output - Wordpress itself, unaltered, comes to mind, as does Magento. I’ve also seen good coders put out working beautiful websites that can’t pass validation for one or more reasons. I already gave one - using browser prefixes will prevent the CSS from being valid even though they are necessary to get the desired effect, particularly with Safari.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.