Pedantic musings

For technical support for all editions of CSS HTML Validator. Includes bug reports.
Post Reply
alnico
Rank I - Novice
Rank I - Novice
Posts: 15
Joined: Mon Jun 21, 2010 4:07 am

Pedantic musings

Post by alnico »

There are many people out there (like me, for instance) who use CSE-HV, to get websites to validate under the most stringent conditions. I was wondering if you could help add two additional messages (as suggestions) for pedants out there:

1. Use of OBJECT instead of IMG as the W3C was planning to phase IMG out. (http://www.w3schools.com/TAGS/tag_object.asp) . Also mention a word of caution that OBJECT does not render well on IE and server site sniffing would be needed.

2. Use of text/javascript when the MIME should be application/javascript. Again, a word of caution for IE.
PS Bugs: I noticed that HTML Validator did not check if an external javascript source was contained in a .js file or not. I changed the src=example.html and it passed validation! Can this be fixed please?

3. Suggest that SVG images be used instead of PNGs if possible, or PNGs and SVGs be used over GIFs.

Thanks!

User avatar
MikeGale
Rank VI - Professional
Rank VI - Professional
Posts: 714
Joined: Mon Dec 13, 2004 1:50 pm
Location: Tannhauser Gate

Re: Pedantic musings

Post by MikeGale »

It's good to have questions like this. Thanks.

My view is a both more pragmatic and in favour of greater flexibility.

If I'm not mistaken SVG (which I have been a fan of for many years, I programmed an SVG graph production system years ago, I am still proud of that!) is not yet that widely supported in browsers. If that's the case it's not ready to be recommended ahead of other formats, where your target is the general browser population.

In my view one of the great untapped potentials is for the more sophisticated content (for example CSS and JavaScript) to be custom generated by code. That has a lot of potential, though I don't often notice it being done! As much generated content is limited in the extensions that it can use, I'd recommend not unduly discouraging such usage!

alnico
Rank I - Novice
Rank I - Novice
Posts: 15
Joined: Mon Jun 21, 2010 4:07 am

Re: Pedantic musings

Post by alnico »

As per Wikipedia, I believe most popular elements of SVG are widely supported by standards-compliant browsers today. The upcoming IE9 promises native SVG rendering, so its just a matter of time before SVG becomes commonplace. I serve use a PHP content negotiation script to serve up SVG, application/javascript and OBJECT to standards-compliant browsers (FF, Opera, Chrome, SafarI), and PNG images & older tags to those browsers that do not identify themselves as compliant. It's a win-win for all with just the help of a bit of extra coding. I also use compressed SVG which really make my graphics fly!

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3478
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Pedantic musings

Post by Albert Wiersch »

alnico wrote:1. Use of OBJECT instead of IMG as the W3C was planning to phase IMG out. (http://www.w3schools.com/TAGS/tag_object.asp) . Also mention a word of caution that OBJECT does not render well on IE and server site sniffing would be needed.
I don't think this would be a good idea yet as "img" is well-known and is likely to cause fewer problems because it's been around and supported a long time.

Or, perhaps I could add a new category like "Future Compatibility" and display a message in that category about recommended "object" instead of "img"? I could assign all those messages a flag so a user could disable them if they wanted.
alnico wrote:2. Use of text/javascript when the MIME should be application/javascript. Again, a word of caution for IE.
That's true, but it seems real-world browsers work better with "text/javascript" and it seems that some versions of IE may not run script with "application/javascript":
http://blogs.sitepoint.com/2008/05/13/j ... -you-dont/
http://javascript.about.com/od/hintsand ... ptmime.htm

So, being that CSE HTML Validator is more designed for the "real world", I think it should accept what works in the "real world"... of course I could display a message that "text/javascript" is technically incorrect, but would that be useful? What exacly do you think CSE HTML Validator should do? What should it say, if anything, if "text/javascript" is used?
alnico wrote:PS Bugs: I noticed that HTML Validator did not check if an external javascript source was contained in a .js file or not. I changed the src=example.html and it passed validation! Can this be fixed please?
CSE HTML Validator doesn't look into the files to see what's in them, but I could possibly display a warning message for ".html" files, by just looking at the extension. Does this seem like it would be reasonable and helpful?
alnico wrote:3. Suggest that SVG images be used instead of PNGs if possible, or PNGs and SVGs be used over GIFs.
I think this would be unnecessary and confusing (at least suggesting SVG). However, a message about using PNG's over GIF's might be useful... but then again, GIFs support animation and PNG's don't (or do they?) so someone might really want to use GIFs... but they could always disable the message. Hmmm... not sure. Any further thoughts on this? I'm thinking a message about the superiority of PNGs might be appropriate if a GIF image is used. Does that sound like a good idea?

alnico
Rank I - Novice
Rank I - Novice
Posts: 15
Joined: Mon Jun 21, 2010 4:07 am

Re: Pedantic musings

Post by alnico »

Hi Albert,

Thanks for the replies.

1. IMG vs OBJECT
I just tested it out with IE8; and IE8 does serve up a PNG image, but it does have some quirks (treats it like a QuickTime application initally; the height and width should be specified, and a no-border css value should be present)

I recommend that you could have a comment that says:
"Comment: The W3C recommends the OBJECT tag instead of the IMG tag. However, using the OBJECT tag to display an image, may trigger quirks in Internet Explorer 8 if the image size is not set. Additionally, it and may not render correctly in IE7. If you use scripting to render browser-specific content, consider serving images by using OBJECT tag for standards-compatible browsers.
2. application/javascript
Although application/javascript does not work with IE8, you can put a comment similar to the one above.
"Comment: The correct mime type is application/javascript. However, Internet Explorer ignores the "application/javascript" MIME type when used. If you use scripting to render browser-specific content, consider serving the javascript MIME type by using "application/javascript" for standards-compatible browsers.
3. JS file extension
I would suggest that if CSE finds "text/javascript" or "application/javascript" in a tag, it immediately checks if the src attribute value has an extension of .js; else throw a caution. (Note that some Google search/adsense scripts do not have a js extension). [It's always good to caution a user nevertheless]

4. SVG images
You could have a comment with the following text:
Comment: Did you know that you can use SVG vector images instead of PNG/GIF? SVG images can offer better quality, scalability, and smaller file sizes.
5. PNG images
MNG and APNG are the animated counterparts of GIF, but browser support is poor. You could have a comment with the following text:
Comment: If your GIF file is not animated, you can consider using the PNG format instead. PNG offers much greater quality and lower file sizes. Additionally, you can also consider using SVG images that are vector formats, and offer several advantages over PNG and GIF.
Hope this helps. It would give users that much more information when coding. General knowledge through such comments above is always a good thing. :)

User avatar
Albert Wiersch
Site Admin
Site Admin
Posts: 3478
Joined: Sat Dec 11, 2004 9:23 am
Location: Near Dallas, TX
Contact:

Re: Pedantic musings

Post by Albert Wiersch »

alnico wrote:Hope this helps. It would give users that much more information when coding. General knowledge through such comments above is always a good thing. :)
Yes! That is helpful. I plan to implement some (but not all) of these messages and checks for the next update. Thank you!

UPDATE: In the next update, CSE HTML Validator will now:

* Check script "src" values for a "js" extension if type="text/javascript" or type="application/javascript" and generate a warning if the extension is not "js".
* Warn if type="application/javascript" is used because of IE8's lack of support for it.
* Generate a Tip message about PNG images if a "gif" image is detected
* Generate a message about type="text/javascript", saying that although it is not technically correct, it is still recommended due to wide browser support.

The actual error messages may have more detail and more information.

As of now, I think it may be too confusing/problematic to suggest OBJECT over IMG and to recommend using SVG images.

Post Reply