| HTML Structure Validation - Who Cares? |
|
|
|
Written by Mark Whitman April 2, 2006 Every once in a while I receive a note frantically warning me that the HTML on a site or page I created does not pass an HTML validation check. I typically shrug this off, "who cares?". I've always considered HTML validators to be a tool useful to someone just learning HTML but other than that - useless. My own code rarely if ever passes HTML validation because I don't use quotes around tag attribute values unless they are necessary (why bother?). The only time quotes are necessary in terms of web page functionality is when the attribute value is more than one word. Examples: 1 - this won't pass HTML validation because only one value is quoted:
2 - this *would* get a validator's blessing:
Can anyone share a *good* reason why I should care whether an HTML validator likes my use of quotes around multi-word attributes only? Mark Whitman Written by Michael Motherwell April 4, 2006 There are some questions, Mark, that get far more airplay than they deserve. This is one such question. Does it matter? If you are the sort that thinks small passages in the Bible are valid justification for {INSERT WHATEVER HERE}, then the validation religious debate might be just the online cause for you. Either that or big endian little endianism. If, however, you are like me and have the desire for a life, have laundry that needs doing, loved ones to call and generally a life, then let absolute compliance go, as it is a goal that takes far more effort than it offers rewards. Now, before the full force and rage of this issue is directed towards yours truly, full compliance is a worthy goal and a good idea in theory for a whole stack of reasons, like cross device accessibility and future proofing. But really, if you do most things right, and the validator nit picks like an angry maths teacher, just accept that 100% is a good goal, but not always the best use of one's time or life's energy, especially when there is important work to be done, like watching yet another Simpsons rerun (WYASR for short). Michael Motherwell Written by Adam Bostock April 4, 2006 Hi Mark Adding quotes as shown in your example is good if you want to be compliant with the new XML languages, including the XML version of HTML, which is XHTML. Kind regards Adam Bostock, Innovation Consultant AcroLogic.co.uk Written by Jim King April 4, 2006 Reasons to validate: 1. I update pages a lot, and if I start with valid HTML, it's pretty easy to run the validator and quickly find any typos I may have inadvertently introduced. 2. I find that having valid HTML is a better starting point to get a page to render properly in a variety of browsers. Valid HTML doesn't mean you don't have to work on proper rendering, but having an undiagnosed HTML error is a sure way to frustrate yourself trying to render the page properly. 3. To my knowledge, no search engine representative has ever stated that clean HTML is in the ranking algorithm, but it's possible that some links can be hidden from a robot because of an HTML error. When valid HTML is a criteria, I'm ready. 4. Telling the browser what the doc type is and then faithfully staying with the standard has got to speed up the page rendering. Anytime you ask the browser to parse extra things on the fly, you slow it down. Jim King borderline-productions.com Written by Martha Retallick April 4, 2006 The best reason for using a validator is to make sure that your site conforms to Web Standards. A website that is designed to meet Web Standards is one that conforms to the Internet's internationally accepted “rules of the road.” And, you may be asking, what happens when you use Web Standards? Six things, and they're all good: 1. Your site becomes available to a wider variety of devices than just a computer, such as Internet-enabled cell phones and Personal Digital Assistants (PDAs). 2. Your pages download and display faster, which means that your visitors will be more willing to stick around and see what you have to say. 3. Your site becomes accessible to blind and low-vision users. 4. You’re using less bandwidth. And since your web host charges you based on the amount of bandwidth you use, the less you use, the less you pay. 5. It’s easier and faster to maintain a Web Standards-based site. That's because these sites are built so that structure and presentation are separated. Which means that if you want to change how your site's headlines look, all you need to do is change one file, and the headlines are automatically updated to your new style. 6. Ever wanted to print out a page, only to have it come out with some of the text missing? With a Web Standards-based site, every page can be a printer-friendly page. No more hunting for that little “printer-friendly” icon! In short, both you and your website visitors will enjoy many benefits if your site conforms to Web Standards. Martha Retallick Western Sky Communications Written by Tom Aman April 4, 2006 Mark, Your coding only works because browsers are *very* forgiving and will try to do their best, even with incorrect HTML. It means that they will guess at the intent of the coding. Too many people do not realize that the whole hypertext / HTML system was based around the server (in this case, the HTML source) being made as correct as possible and the client (browser) being as forgiving as possible. The idea behind this was this to give the surfer as few bad experiences as possible. The hidden benefit is that correctly coded HTML will be parsed more quickly by the browser since it avoids having to execute the extra code that is invoked to handle exceptions to good HTML. Basically, when a parser sees a keyword such as "type", it first looks for the "=", then, finding that, it will look for the first non-space character following that "=". If that character is a single or double quote, it will take the value as being everything from the character following up to and including the last character before the closing and matching single or double quote - a very simple scan. If that character is not a quote, then it *assumes* the value intended is everything from that first non-space character up to the character before the next space. Weird things can happen if a typo puts something really unexpected within that grouping. The correct use of quotation marks is one of the key elements of coding good HTML. To leave them out forces the parser into performing extra operations to determine the intent, not only to find the beginning of the value, but also to decide when it has reached the end. Consider, in your coding, if you miss a space (i.e a typo results in type=textname=item), not only will the browser get your intent wrong but, since you would ignore validation warning of missing quotes, a validator will not help you find it. If you *always* use quotes, then the missing space is less likely to cause problems since a browser would still be able to get your intent correctly, also a decent validator would be able to catch the error so you could correct it, thereby guaranteeing a correct result. The second problem with leaving out quotes is that there is no guarantee that all browsers will handle it correctly or that future version of existing browsers will continue to handle it correctly. There was a time, in the early days of the Internet, when quotes were often not used and browsers would handle it OK anyway. Thus an anchor such as <.a xhref=/somedirectory/my page.html>... would get the correct page. Browsers would interpret is as intended http://host/somedirectory/my page.html. Now, a reference coded in that manner would be interpreted by a modern browser as http://host/somedirectory/my Obviously, that would result in a "404 Not Found" error for the surfer. So, the main reason you should care what an HTML validator says about your HTML is to ensure your pages will *always* be interpreted correctly by current and future browsers. Tom Aman Aman Software Written by Mark Whitman April 6, 2006 > To leave [quotation marks] out forces the parser into > performing extra operations to determine the intent, > not only to find the beginning of the value, but also > to decide when it has reached the end. - Tom Aman White space is interpreted the same way as quotes - that's why you need quotes around multi-word tag attributes. There is zero additional overhead when not quoting single word attributes, at least not with Apache - I assume it's the same on a Windows server. If anything, using quotes when not necessary increases file size therefore making the page load slower (by a millisecond or 2 :) > The second problem with leaving out quotes is that there is no > guarantee that all browsers will handle it correctly or that future > version of existing browsers will continue to handle it correctly. In the 12 years I've been using HTML this way I have never found a browser, graphical or text, that can't tell the difference between a quote and white space (where tag attributes are concerned). I doubt this will ever change but who knows, usually however software is as backward compatible as possible. Getting [uptight] about quoting tag attributes achieves nothing, it never has and probably never will. Mark Whitman Written by Lee Roberts April 7, 2006 > Can anyone share a *good* reason why I should care whether an HTML > validator likes my use of quotes around multi-word attributes only? - Mark Whitman Seems Mark was asking a specific question here and is really curious as to the phenomenon he has encountered. The answer is really simple. Multiple word attributions are not clearly understood by user agents and have not been since the beginning of user agent development. Multiple word attributions will never be understood by all user agents. The reason is, they are not computing programs that process and evaluate data based upon algorithms that can be programmed to handle the diversity of human slang and jargon. Let's see if we can open this can a little wider and peer into it for a better visualization. You'll notice that you can have a width of 100 without quotation marks, but you can't have 100% without quotation marks. The reason is simple, the % is a programming character. Because of this, the values need to be delimited with the quotation marks. Single word attributes are followed by either a single greater than sign to close the HTML tag or a space. The delimiting of an attribute is performed by the equal sign and the space. Since the a space is a delimiting character, the next words in a multiple word attribute are stray words and the tag is considered broken. This will cause different behaviors in different user agents since not all user agents are created equal. Case in point, Internet Explorer 6's CSS support is 4 years or more behind other modern-day browsers. Therefore, it is suggested and regarded as not acceptable to have multiple word attributes without quotation marks. It's all about universality. Martha Retallick attempts to make some very good points about why one should validate HTML codes but some concerns arose. > Your site becomes accessible to blind > and low-vision users. Using HTML or XHTML standards does not guarantee the Web page or Web site will be accessible. That's why we have the Web Accessibility Initiative consisting of the Web Content Accessibility Guidelines, User Agent Accessibility Guidelines and the Authoring Tools Accessibility Guidelines. Without the Web pages / site being developed under these guidelines, they are not accessible. Case in point, many HTML attributes are wrongly used in uneducated attempts to increase search engine positions. These consist of the table summary, HTML title attribute, image long desc and others. By improperly using these attributes a Web page quickly becomes inaccessible. > It's easier and faster to maintain a Web Standards-based > site. That's because these sites are built so that structure > and presentation are separated. Web standards does not require the separation of structure and presentation. HTML standards can be met without using CSS. Accessibility can be met without using CSS. HTML 4.x has existed longer than CSS has and therefore can be be met without CSS. The advantages highlighted are not valid reasons for a Web Standards-based site because the same advantage of changing segments of your Web pages across the entire site can be easily done in Dreamweaver, FrontPage, GoLive, SHTML, PHP, ASP, JSP, ColdFusion and more by modularizing your designs. > With a Web Standards-based site, every page > can be a printer-friendly page. No more hunting > for that little "printer-friendly" icon! Using HTML / XHTML standards does not guarantee success for this situation. CSS on the other hand does help with this, but does require the developer to understand the nuances of printed CSS layouts. Using HTML / XTHML standards aids in delivering usable Web sites. The reason to validate a Web page is to ensure compliance with the HTML / XHTML standards. Through compliance with the HTML / XHTML standards your Web pages will achieve universality and reduce the problems visitors may encounter due to poor coding and human error. Accessibility is achieved through a clear understanding of what user agents can do and the visitors to your Web sites. Without this understanding you're still trying to be the fastest gun in the West and something bad is bound to happen. Sincerely, Lee Roberts roserockdesign.com applepiecart.com Written by Rayburn Taylor April 9, 2006 The W3.org says this about quoting tag attributes: ------------------- "By default, SGML requires that all attribute values be delimited using either double quotation marks (ASCII decimal 34) or single quotation marks (ASCII decimal 39). Single quote marks can be included within the attribute value when the value is delimited by double quote marks, and vice versa... We recommend using quotation marks even when it is possible to eliminate them." ------------------- Rayburn Taylor taylorsbookpage.com Written by Mark Whitman April 9, 2006 Thanks to those who responded to my HTML validation question. In some cases I think you lost sight of what I was describing (not putting quotes around HTML tag attributes unless they are multiple words - which BTW is valid HTML). The fact remains however that the responses validated my assertion on the subject - HTML validators are useless unless you're trying to learn to tag HTML files manually (a very good idea), basically don't know what you're doing, and need some help trying to figure out where you went wrong when a page doesn't display as expected. If your web page displays properly in IE and FireFox you've got valid (enough) HTML. So for those on this mailing list who know me, thanx for your concern but I couldn't care less if HTML validators like my attribute quoting style so please don't contact me with your HTML validation warnings because then I just have to spend time explaining why it doesn't matter (for experienced, competent developers anyway). I appreciate the concern though :) Mark Whitman Comments (3)
![]()
Diamond
said:
|
|||||||
| To a certain extent I agree with you... If you have to crank out a bunch of garbage all the time then yes it is a waste of time; and by garbage I mean disposable content. If I was designing a viral campaign or a grassroots campaign for a time sensitive issue then by all means good enough usually takes a little more time then I should spend. If however you are generating html that will be archived in any type of knowledge store, creating a brand identity or creating a growing or established corporations identity then strict adherence to standards is a professional obligation/responsibility. There is never time to re-factor code be it Java, HTML or Operating Systems... So we upgrade instead? Saying valid html is a best practice and shrugging it off because it doesn't seem relevant in your situation is like a dentist opting out of wearing rubber gloves because your under and the latex irritates his skin; If most people woke up they would probably say something. It's true your client will probably never send you a fruit basket because they recently re-branded and accidentally converted all the old site content when they uploaded main.css; As a professional you should consider the investment that is being put into your efforts. (Kinda like using short concise statements) Value can only realized if it's present. If you build HTML correctly it's contents should be useful in ways you can't imagine. So don't think that because you don't see a need that it is not there. If you have been schlepping out invalid HTML with no regard for DOC type or understanding of what it is... Billing your sites as professional web development... You are again guilty of misrepresenting the capability of your work. If the green light is ever out on a site I developed I can tell you why and the line number and I just now decided to include a section of comments at the top of the page with justifications for any invalid html. It's always easy to justify not being responsible just like it is always difficult to be responsible I guess the mark of a true professional in this day and age is having a good marketing department. |
Sam Hills
said:
| When I'm trying to debug a complex page (and some pages can have hundreds of lines, or more!) that won't render properly, I often use the HTML validator in FireFox to see if there's a problem such as a missing closing tag. I'd MUCH rather put in the quotes than to have to wade through several hundred "invalid attribute value" errors trying to find the one actual relevant error message. |
Your Would-be Employer
said:
| Let's say I'm interviewing for a Web Developer position, and I'm trying to decide between two candidates with equal server-side programming skills. You send me your site as an example of your work, while the other candidate sends their example with valid HTML. You lose. |
Write comment





