HTML Validation Difficult

What is the best way to do HTML Validation? Should I use Dreamweaver or an online website?

I am very intimidated by HTML Validation. I get kind of lost trying to do it.

By the way, how do I know I am using the latest HTML? Is that HTML4.0? Sorry for such an simple question…

The best way to validate websites is to use the W3C Markup Validation Service.

The easiest way (in my opinion) is to use the FireFox HTML Validation Add-On.
(However this points out error/warnings W3C doesn’t consider errors/warnings, and vice versa). For the best results, use “Serial” when the add-on is installed and asks what kind of validation you want.

I don’t know about dreamweaver validation, I don’t use it. (I use NetBeans, code HTML by hand, not WYSIWYG).

And yes, HTML 4.0 is currently the newest version of HTML, though most websites nowadays use XHTML 1.0

HTML 5.0 is in the making and most modern browsers already have some support for that.
It’s up to you to guess which browser doesn’t.
Hint: It’s developed in Redmond …

Personally, I use the W3C validator. But there do seem to be good alternatives, such as Firefox plugins etc.

I am very intimidated by HTML Validation. I get kind of lost trying to do it.

You can always post here for a translation of the results. Really, though, if you do a quick survey of the HTML rules, you won’t go too far wrong, and validation is pretty simple, I find.

By the way, how do I know I am using the latest HTML? Is that HTML4.0? Sorry for such an simple question…

HTML 4.01 has been the standard for around ten or more years now. Typical Doctypes look like this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">

HTML5 is still being invented and isn’t ready for use. XHTML 1.0 / XHTML 1.1 is a popular variant that has found itself in a kind of dead end street, but it has stricter validation rules and doesn’t work properly in IE anyway, so it’s not worth bothering with IMHO unless you have a specific reason for using it (like doing something with XML… whatever that might mean!)

XHTML doesn’t work properly with IE if you use the text/html+xml content type. When you simply use text/html IE can handle XHTML just fine!

… because it is served as HTML. Which defeats the purpose of using XHTML in the first place. :slight_smile:

:lol: Not another XHTML/HTML war! Let’s just agree that both sides have their positions and their arguments.

…even though HTML Strict is the proper language to use 99% of the time… :wink:

All right, then I’ll just say I use XHTML 1.0 Transitional, serve it using the content-type text/html, and I’m happy with that setup.
No need to agree with me, everyone has their own preferences :slight_smile:

:lol: Scallio, mine was a cheap shot. “Let’s just not fight, even though I’m right and you’re not.” Shades of my first marriage…

That might be OK, as long as you don’t mind having the browsers that do support XHTML not render the pages in strict mode.

I serve XHTML pages as XHTML to browsers that support it, and XHTML pages as HTML to those that don’t.

I’m not 100% convinced it’s 100% reliable but it seems to be - i.e.
NOT user-agent sniffing but

if (stristr($_SERVER["HTTP_ACCEPT"], "application/xhtml+xml"))

As for validation, First, don’t worry if you don’t quite understand exactly what the error messages are saying, they become easy after you know what they mean. Well OK, that sounds dumb, but you’ll get them. And if you have trouble, as said, don’t be afraid to ask here.
Second. don’t feel overwhelmed by the number of them. Most often a single error will generate multiple error messages eg. a single unentitized ampersand creates 5! http://www.sitepoint.com/forums/showpost.php?p=4529357&postcount=3
So as you fix things and revalidate the number of them should go down relatively quickly.

Mostly, if you pay attention to why the validation errors occur, you can then make sure that your later work follows the same standard.
Before long you’ll be writing HTML code that passes validation with no trouble.

I also suggest the horse’s mouth [W3C] but I personally use the Fx plugin as a precursor. The DW Validation for the markup is similar to TIDY but the explanations it produces are sometimes nonsense.

Like was mentioned; a lot of the errors and warning are cascading and a caused by different unrelated things. So one trick is; you can sometimes use the comments <!-- –> to omit small sections of code while tracking errors so you can narrow-down the culprits.

Don’t get intimidated, instead use the w3.org Validator with the “Clean up Markup with HTML Tidy” checked, and you’ll get an automatically cleaned code outputted.

Copy the code the validator outputs at bottom of the validate message page, and you’ll have most of the counted errors fixed. :slight_smile:

Then after testing that fixed code, validate it again and try fix the remaining errors manually. Mostly the errors are self explaining if you look closely. Warnings you can consider later.

If you get stuck, post both the error message and your line of code for help.

This is a very useful trick. It’s saved me hassles to no end in my work. Good cite, Robert.

I used the Validation tool. It’s cool!
But my web page won’t center now! Can anyone tell me why? Is it because I should have a <div> around the entire website and then center it?
What is the CSS way of centering? I did not see “center” in the choices.

To center the contents of an element, you set the left/right margins of the container to auto.


#container {
    margin: 0 auto;
}

See for example:

http://www.w3.org/Style/Examples/007/center
http://www.maxdesign.com.au/articles/center/
http://simplebits.com/notebook/2004/09/08/centering/
http://www.thesitewizard.com/css/center-div-block.shtml
http://css-discuss.incutio.com/?page=CenteringBlockElement
http://help.veign.com/css-center-webpage.php

I’m not a CSS expert so you may have better luck in that forum, but I usually use margin, padding, and/or text-align when I want to center something.

It can get tricky with inheritance from parent containers and all sometimes, but for centering your “body” I think it would work if you put

body {
  margin: auto;
 }

in your CSS file.

Centering via the body fails in some older browsers. This is why a container within the body is commonly used.

The CSS Forum is where you’ll find in-depth information about this.

It was centered until I used the validated source code.

Remember to set a width on the container too, or auto margins won’t do anything.

E.g.


.c2 {
    margin: 0 auto;
    width: 970px; /* alter to suit */
}

Where no width is specified, the default width of the block will be used instead. This is very useful for when designing liquid layouts.

In some situations the block will be at full width due to its content, so in those specific situations setting the width to be smaller than the full width allows the effect to take place.