• 13
• 18
• 19
• 27
• 9

# [web] Validation and Whatnots.

This topic is 4191 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

First, I would like to point out that the W3C's publications have become increasingly difficult to understand. In fact, I now have almost no idea about what I'm "supposed" to be doing with my webpages. I would like for my page to validate. Because... well, because it shouldn't take that many changes. Besides adding ALT tags and removing ampersands in my links, I apparently need to state my DOCTYPE and Character Encoding on my pages. I think I figured out what to do with the character encoding. I've added
<meta http-equiv="Content-type" content="text/html;charset=UTF-8">
to the top of my header tag. I don't think I have any special characters that need anything complex and the page still looks fine, so I'm assuming this is okay. But I have no idea what my DOCTYPE is, or how to add it, or where. I'm using moderately standard HTML with nothing more complex than some tables, a div or span or two, and some CSS 2.0. Specifically, what do I need to add, and where? I would love some help on this one - it shouldn't take too much. [smile] My Site W3C DTD List ...Also, is it really necessary for me to have ALT tags all over the place? What about images that already have an informative TITLE tag?

##### Share on other sites
As far as the character encoding goes, I think a default declaration is something like this:
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

The <!DOCTYPE> tag is the first thing in your page. It comes before the <html> tag. It tells the browser which HTML or XHTML specification your website uses.

For example:
Quote:
 blah

##### Share on other sites
Which doctype you should go with is beyond the scope of what we could explain, but google has plenty to offer on the subject (but W3C docs are not made for real humans, i agree).

I never felt that charset specifications were important until i started my latest job. We have documents that were originally written in MS Word, copied into FrontPage, and exported into HTML. Character set and conversion issues are a nightmare, to say the least.

If you have the wrong charset, you get all kinds of funny squiggles and question marks. Browsers try to auto-detect what you have on the page, but manually setting it saves the browser some confusion.

If you want to validate easily, i would suggest getting the Firefox WebDev extension. It makes validation only a right-click away.

##### Share on other sites
A meta tag describing what encoding you use isn't mandatory- but it's a good idea to tell the browser either via a HTTP header OR meta tag (If you use both, be sure that they agree).

Otherwise, the browser has to guess.

Most systems will default to iso-8859-1 if you don't specify it. Use something like Firefox "Web Developer" or "Live HTTP Headers" extension to see the headers.

The doctype definition actually changes the behaviour of some browsers (well, at least Mozilla and MSIE). Therefore it's really important to get it right.

Well-formedness is the final thing to do - if your pages aren't well formed, the browsers have to guess what you meant. This guesswork is a bit hit-and-miss - and different browsers may make different guesses, which increases the chance that your site will behave differently across browsers.

Escaping ampersands in links isn't really that tricky:

<a href="something?x=42&amp;y=99"> ...

Mark

##### Share on other sites
Quote:
 Original post by Avatar GodFirst, I would like to point out that the W3C's publications have become increasingly difficult to understand. In fact, I now have almost no idea about what I'm "supposed" to be doing with my webpages.

To be fair, I don't think it's so much that the W3C's publications have 'become' difficult to understand. It looks more like you don't really know what kind of document you are creating! This is probably the fault of all those people who develop web pages without caring about such standards, meaning much of the tutorial material we work from ignores all this.

And if you don't know what document you're creating, expecting it to validate is optimistic at best. :)

Quote:
 But I have no idea what my DOCTYPE is, or how to add it, or where.I'm using moderately standard HTML with nothing more complex than some tables, a div or span or two, and some CSS 2.0.

If it's only 'moderately' standard, it won't validate. You can't have it both ways. ;) You pick a single standard, work to it, then it'll be fine.

Personally, I pick the XHTML strict standard. It's reasonably clear on how to use it.

Quote:
 ...Also, is it really necessary for me to have ALT tags all over the place? What about images that already have an informative TITLE tag?

They're attributes rather than tags, btw. The title attribute is to add extra information about an element. The alt attribute is to provide replacement text in the event of the image not being displayed. There's considerable overlap here when it comes to images but the two things really do have different meanings.

##### Share on other sites
Well, Kylotan, you're right about that. I've never really known (or cared) what my doctypes were because the pages worked in every major browser I could find.

"Moderately standard" as I used it in my last post didn't really mean anything except that I don't do anything overly weird with my code.

And, yes, I know escaping ampersands is easy; that's why it was already done by the time the first person posted a reply. I just hadn't realized that it could be a problem until W3 told me...

As I test Doctypes, I find that my page does validate entirely as HTML 4.01 transitional.

As XHTML 1.0 Transitional, I have 149, but they all deal with omitting the slash in a closing tag, incorrect tag order, or lack of quoatations around various attributes. So, I suppose I could easily make my site XHTML valid. Also, since none of these changes should affect the way the page is viewed, I suppose I should go ahead and do it, just for the sake of appeasing the XHTML gods.

##### Share on other sites
Quote:
 Original post by Avatar GodAs XHTML 1.0 Transitional, I have 149, but they all deal with omitting the slash in a closing tag, incorrect tag order, or lack of quoatations around various attributes. So, I suppose I could easily make my site XHTML valid. Also, since none of these changes should affect the way the page is viewed, I suppose I should go ahead and do it, just for the sake of appeasing the XHTML gods.

Yes, we are most displeased with your lack of... progress. Get to work! We demand it! ;)

##### Share on other sites
I think Fix Your Site With the Right DOCTYPE! is a good introduction, despite the fact that it was written in 2002. As markr mentioned, the DOCTYPE is very important, because it can determine whether or not a browser renders your page according to it's best approximation of standard or a technique "compatible" (aka quirks mode) with who knows what all. Indeed, simply having a blank line before your DOCTYPE can trigger quirks mode in IE. It may not be a huge concern depending on the site, but knowing what mode your site is rendering in on different browsers may save your your hair.

##### Share on other sites
Heh.

A surprising amount of CSS code stops working once I declare my site with a DocType.

Quote:
 Using an incomplete or outdated DOCTYPE—or no DOCTYPE at all—throws these same browsers into “Quirks” mode, where the browser assumes you’ve written old-fashioned, invalid markup and code per the depressing industry norms of the late 1990s.
In fact, I have used invalid markup and code per the depressing industry norms that I learned in about 96 with my first site...

Thanks for the help and the links! Gotta mess around with some things, now.