w3c validation

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
rsmarsha
Forum Contributor
Posts: 242
Joined: Tue Feb 08, 2005 4:06 am
Location: Leeds, England

w3c validation

Post by rsmarsha »

I've recently changed the doc type on a site i have to XHTML 1.0 strict. I'm now having validation errors. One is with border="0" in images tags, so i created a CSS style to set border to none, which works in firefox but not in IE.

Code: Select all

.borderless {
border-style: none;
}
Also the gaps i had between columns vanish when i put this doc type in. <hr> tags are not allowed to have width so i put in CSS for that and it doesn't seem to work.

The site is one i havn't updated for ages, was going to design a new layout, but before i do i want to get the current one to work with the doc type i have. Site is http://irealms.co.uk, any idea on what i need to change for it to validate?
rsmarsha
Forum Contributor
Posts: 242
Joined: Tue Feb 08, 2005 4:06 am
Location: Leeds, England

Post by rsmarsha »

The odd thing is, when i put the CSS in as a style attribute within the html tags, it works, but when i put it in the stylsheet and used a class within the tags it didn't.

It doesn't like the target attribute in a link, how do i get it to accept that? Also i have lots of these errors.

Error Line 29 column 26: document type does not allow element "hr" here; missing one of "object", "ins", "del", "map", "button" start-tag.
<hr style="width: 20px;" />
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Post by matthijs »

border:none
or
border-width:0;
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Post by matthijs »

It doesn't like the target attribute in a link, how do i get it to accept that?
You can't. If you need the target attribute (why?) you'll have to go for a transitional doctype.
Error Line 29 column 26: document type does not allow element "hr" here; missing one of "object", "ins", "del", "map", "button" start-tag.
<hr style="width: 20px;" />
That's because you have a hr inside a p. I think that's the problem.

And about the other errors: the validator tells you exactly what's wrong. You have to get used to the language a bit. But the error reporting together with some checks at w3schools and the css specification or a good book should be enough to get rid of all errors.

Else, let us know
:)
rsmarsha
Forum Contributor
Posts: 242
Joined: Tue Feb 08, 2005 4:06 am
Location: Leeds, England

Post by rsmarsha »

Yeah a lot of those errors are tags inside <p>.

<p> is used to give padding around the text.

Code: Select all

.columnspacer {
padding: 5px 5px 5px 5px;
}
Tried using <div> instead of <p> but that padding doesn't show when i use div for some reason.

Got rid of the errors, but the padding around the text won't work when i changed the p spacers to div's.
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Post by matthijs »

Well, it's very simple. A paragraph must/should be surrounded by p tags. To group a section of a page use a div.

Both should work fine with margin and/or paddings. Although you'll have to read about the concept of "margin-collapsing", otherwise you'll get surprising results sometimes.

And don't forget you can target many elements without giving everything a seperate class or id (that's called "classitis" and "divitis").
Like:

Code: Select all

<div id="maincontent">
<p>Text</p>
<p>More text</p>
</div>

css:
#maincontent {
width:500px;
background:#eee;
}
#maincontent p {
margin:1em 0;
padding: 0 20px;
color:#444;
}
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

try

Code: Select all

a {
border: 0px;
}
rsmarsha
Forum Contributor
Posts: 242
Joined: Tue Feb 08, 2005 4:06 am
Location: Leeds, England

Post by rsmarsha »

Thanks for the tips.

I had the margin's between the columns working, until i added the XHTML doctype. Now they seem to have vanished.

http://www.irealms.co.uk

Also my css validates but i have warnings about elements not having a background color if they have a color, and vice versa.

I'm primarily a html,php,mysql person. :) But trying to rework from tables to css and put the right validated code in. :)

Maybe my browser is playing up but without the www. the margins appear and the text changes.
Post Reply