1 (edited by MattF 2007-08-05 15:59)

Topic: W3C validation

Just a quickie. big_smile Has anyone else been having a problem with the W3C validator showing messages/errors that don't appear to make sense? Keep getting errors on the forums page, yet the portal page classes as clean, according to the W3C validator. Most of the errors it emphasises are from code/html that is on both pages, however. Running the page against the FF HTML validator plugin lists it as clean. Just wondered whether anyone else is having this head scratcher, or whether I'm missing something blatantly obvious.


Cheers,

Matt

Re: W3C validation

Link? I might be able to help wink

3

Re: W3C validation

Smartys wrote:

Link? I might be able to help wink

smile big_smile Knew I'd forgotten something. big_smile This is the link to the W3C validation page showing the errors:

http://validator.w3.org/check?uri=http% … mp;group=0

This is the direct URI: http://forums.bauchan.org/toyota/forums.php

This URI validates fine: http://forums.bauchan.org/toyota/index.php

I have a feeling I may be missing something blindingly obvious, but have no idea what. big_smile big_smile


Cheers,

Matt

4

Re: W3C validation

Try closing the meta tag on line 4 properly i.e. put a space before the /
In fact, do the same for all the other self closing tags.

5

Re: W3C validation

Paul wrote:

Try closing the meta tag on line 4 properly i.e. put a space before the /
In fact, do the same for all the other self closing tags.

Had tried that the other day with all the header /> tags, but still the same. Have done it again just to double check though, and still the same. The spaces are all there, in the header section itself now.

Would they affect Xhtml though? Just asking for future reference btw, not to be disagreeable. big_smile If that is likely to cause a problem at all, I'll get all of those altered in the code. I thought they were only for possible compatibility issues with really old browsers?

Re: W3C validation

XHTML requires that tags either have closing tags or be self-closing: without the space I'm not sure if it's really self-closing.
But yeah, it does look like there's something funky with the Validator.

Re: W3C validation

Didn't have the time to look to closely at your code, but the error is caused by exessive use of   causing the validator to break. I just ran the following regex on your code

(?: ){2,}

(deleted the matches) and it solved all of the errors

Re: W3C validation

Yup, way too much useless non breaking spaces. These have very specific meaning, and should be use only when necessary (i.e. never for graphic or layout issue).

9 (edited by MattF 2007-08-05 21:38)

Re: W3C validation

Jérémie wrote:

Yup, way too much useless non breaking spaces. These have very specific meaning, and should be use only when necessary (i.e. never for graphic or layout issue).

That I can understand, even though it does seem a tad naff if the validator can't parse it properly. big_smile For simple indentation and such though, what preferable method is there? Trying to do that via css would be an absolute nightmare, if possible at all. Is there another indentation technique that can be used?

Edit: I'll rephrase that slightly. big_smile What valid methods are available, which will work across as many browsers as possible, other than using spaces? From what I've been able to gather, just about every other technique is possibly open to various amounts of interpretation by various browsers. Or am I incorrect in that regard? Any advice would be greatly appreciated. smile


Cheers,

Matt

10

Re: W3C validation

Smartys wrote:

XHTML requires that tags either have closing tags or be self-closing: without the space I'm not sure if it's really self-closing.

Have added spaces to all those tags, including <br />, (not updated the actual forum with the new code yet), so at least that part should be in spec now when I update the forum code. Cheers for the pointers from yourself and Paul. smile

Re: W3C validation

MattF wrote:
Jérémie wrote:

Yup, way too much useless non breaking spaces. These have very specific meaning, and should be use only when necessary (i.e. never for graphic or layout issue).

That I can understand, even though it does seem a tad naff if the validator can't parse it properly. big_smile For simple indentation and such though, what preferable method is there? Trying to do that via css would be an absolute nightmare, if possible at all. Is there another indentation technique that can be used?

Edit: I'll rephrase that slightly. big_smile What valid methods are available, which will work across as many browsers as possible, other than using spaces? From what I've been able to gather, just about every other technique is possibly open to various amounts of interpretation by various browsers. Or am I incorrect in that regard? Any advice would be greatly appreciated. smile


Cheers,

Matt

http://www.w3schools.com/css/pr_text_text-indent.asp
Is that what you're talking about?

12

Re: W3C validation

I would have thought that padding and margins would be sufficient for most purposes. Failing that text-indent. I don't see why doing it via css is a problem, its much less work than having to alter the markup. For example, most of those non breaking spaces inside table cells are completely pointless. Use four lines of css to adjust the padding of table cells and you are done. If you want all the cells to have the same padding then only one line of css.

13

Re: W3C validation

Smartys wrote:

http://www.w3schools.com/css/pr_text_text-indent.asp
Is that what you're talking about?

Just going to have a read of that one now. Cheers. smile

14

Re: W3C validation

Paul wrote:

I would have thought that padding and margins would be sufficient for most purposes. Failing that text-indent. I don't see why doing it via css is a problem, its much less work than having to alter the markup. For example, most of those non breaking spaces inside table cells are completely pointless. Use four lines of css to adjust the padding of table cells and you are done. If you want all the cells to have the same padding then only one line of css.

My apologies. Just looked at the source code again. Hadn't realised how much of the padding/indentation is done within tables. smile Would it then be a case of merely adding the text-indent line to the css for that particular table column, to get it all formatted and lined up correctly? I am no css expert, as you can probably tell, so my knowledge on the subject is somewhat limited. big_smile

Just one last question. What/where is use of the space character allowable/preferred, without things throwing a wobbler in future? i.e: is it okay to use two or three for spacing between text, or is that also borderline too? Is there a better way to achieve that effect too?


Thanks again.

Matt

15

Re: W3C validation

Well, call me finnicky, but I've come to the conclusion that the validator is taking the mick a tad. No way can the revised index be classed as excessive in the use of entity spaces. If one can't use valid html entities for visible link spacing to make them distinguishable, and in the code for visible space indicators, it's a tad pedantic. I'm giving up on this one. big_smile Btw Paul, sorted those layout issues within the tables, (I think). big_smile Cheers for your pointers on that gents. smile

Re: W3C validation

All presentation needs to be done in CSS. Never in HTML.

That's quite a simple rule actually.

17

Re: W3C validation

Jérémie wrote:

All presentation needs to be done in CSS. Never in HTML.

That's quite a simple rule actually.

True. However, the simple fact is that CSS is the preference, not the requisite. Even the W3C site only suggests using CSS over html. It's does not require it. Using valid html entities within context is not outside the scope of valid xhtml. Several   for eloquent spacing between links are not excessive. Aspiring to changing it all over to CSS eventually I can understand, but the 'official' validator saying that legitimate xhtml isn't, that is way off the ball. It's piss poor if their parser can be gazumped by technically legitimate styling and/or entities.

18

Re: W3C validation

Strictly speaking   isn't valid xhtml. It only works because the browsers are error tolerant particularly when the page is not being served as xml. It should actually be  & # 160 ;

19

Re: W3C validation

Paul wrote:

Strictly speaking   isn't valid xhtml. It only works because the browsers are error tolerant particularly when the page is not being served as xml. It should actually be  & # 160 ;

Bugga. I'll stand corrected then. big_smile Whilst I'm busy putting my foot in mouth, big_smile how does one go about, within <a href terms, adding spacing between multiple links on the same non broken line within CSS?

20

Re: W3C validation

a {margin-right: 10px}

You should also put an ordinary space between them as well. If you want fine grained control of the spacing then float them left which will collapse the white space and make the margin setting completely accurate. You will of course have to add appropriate css to clear the floats to make the container shrink wrap the links.

21

Re: W3C validation

Paul wrote:

a {margin-right: 10px}

Cheers for that. I can understand that bit. smile

Paul wrote:

You should also put an ordinary space between them as well. If you want fine grained control of the spacing then float them left which will collapse the white space and make the margin setting completely accurate. You will of course have to add appropriate css to clear the floats to make the container shrink wrap the links.

Can I just nod as if I've the faintest idea what that means? big_smile Apologies for being a pain, but any chance of a rough idea of an example, code wise? smile Btw, changed those nbsp's to the #160 for the time being, and that has cleared up the validator errors. big_smile Cheers for that.

22

Re: W3C validation

Think I've almost got it. That piece of CSS is working a treat Paul. Thanks ever so much for that. Just in the process of modifying things at the moment, but everything appears fine upto just. Thanks again. smile

Re: W3C validation

The   thing it good to know, did a global replace for that now myself.

24

Re: W3C validation

Actually, to be really strictly accurate, the situation with   is a bit more complicated. Its valid html and should be valid xhtml. If you are serving xhtml as html then there should be no problem. If you are serving xhtml as xml then the xml parser may well only allow the 5 named entities which are valid xml. The reason for the problem is that an xml parser trying to parse xhtml would have to query the xhtml doctype to ascertain what entites were defined there. If it doesn't do that then it will only regard the allowed xml entities as valid. Since the approach is different from browser to browser it is safer to treat xhtml as if it were xml and only use the 5 named entities permitted by xml which are <, >, &, " and &apos. It should however be noted that &apos; it not valid html.

MattF is probably partly right about the validator. They recently updated it so it could check documents served as xml and it probably needs some fine tuning.

The short answer is if you treat xhtml as if it were xml and use numeric references then you will never have a problem. The alternative is to use utf-8 and enter the real character.

25

Re: W3C validation

Paul wrote:

The short answer is if you treat xhtml as if it were xml and use numeric references then you will never have a problem. The alternative is to use utf-8 and enter the real character.

The good thing about the validator being a tad erratic at the moment is that I now know something I didn't before. Bad thing is that I've wasted cartloads of time today phaffing with php scripts adding CSS code and removing other html bits. big_smile Thanks for the info Paul. I thought I'd done the layout acceptably before, but I now know it can be improved for robustness. Again, thanks for all your advice. Highly appreciated. smile