Almost done :)

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Almost done :)

Post by alex.barylski »

I have received the following errors when validating my site against XHTML strict...

One, is that <A> doesn't support target="_blank"??? WTF how am I supposed to open links in new windows???

Two, is I have used a <label> inside a FORM
Line 50 column 25: document type does not allow element "label" here; missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre", "address", "fieldset", "ins", "del" start-tag.
<label for="catlist">Categories</label>
The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you've forgotten to close a previous element.

One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").
I have no idea how the heck to fix this error...do I have to surround my labels with a P tag or something? Isnt' that overkill???

One more thing :P

I am using tables, but very limitedly...if there are no valign attributes in TD's anymore, how the heck am I supposed to vertically align any content??? There isn't a equivelant CSS attribute is there???
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Re: Almost done :)

Post by feyd »

Hockey wrote:I have received the following errors when validating my site against XHTML strict...
I'd validate against HTML 4.01 Strict.. unless you want to server content to only the few browsers that support the content-type needed for XHTML.
Hockey wrote:One, is that <A> doesn't support target="_blank"??? WTF how am I supposed to open links in new windows???
Javascript trickery. http://www.sitepoint.com/article/standa ... iant-world
Hockey wrote:
Line 50 column 25: document type does not allow element "label" here; missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre", "address", "fieldset", "ins", "del" start-tag.
<label for="catlist">Categories</label>
The mentioned element is not allowed to appear in the context in which you've placed it; the other mentioned elements are the only ones that are both allowed there and can contain the element mentioned. This might mean that you need a containing element, or possibly that you've forgotten to close a previous element.

One possible cause for this message is that you have attempted to put a block-level element (such as "<p>" or "<table>") inside an inline element (such as "<a>", "<span>", or "<font>").
I have no idea how the heck to fix this error...do I have to surround my labels with a P tag or something? Isnt' that overkill???
It's a bit of an overkill. You could just do away with the labels. :o
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Almost done :)

Post by alex.barylski »

I'd validate against HTML 4.01 Strict.. unless you want to server content to only the few browsers that support the content-type needed for XHTML
Cool, ok, whats the validator thing?

Code: Select all

<?php echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
Is what I have thus far...is this correct?

Code: Select all

<?php echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.1 Strict//EN" "http://www.w3.org/TR/html41/DTD/html41-strict.dtd">
It's a bit of an overkill. You could just do away with the labels.
Do you still get screamed at for HTML 4.01 strict?

Aren't labels used by screan readers, etc to announciate the information?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Re: Almost done :)

Post by feyd »

Hockey wrote:Cool, ok, whats the validator thing?
Validator thing?
Hockey wrote:

Code: Select all

<?php echo "<?xml version="1.0" encoding="UTF-8"?>\n"; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.1 Strict//EN" "http://www.w3.org/TR/html41/DTD/html41-strict.dtd">
Lose the <?xml ?> tag and this is the actual doctype

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Hockey wrote:Do you still get screamed at for HTML 4.01 strict?
Image
Hockey wrote:Aren't labels used by screan readers, etc to announciate the information?
Possibly? I can't say as I don't use a screen reader.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Hockey, why not throw a little client side magic into your markup to achieve the new window linking effect? And as for the lables, remember, the <form> element is not a block level element like <p>, <div>, etc. So when you put text inside of <form> tags, you are not necessarily inside a block-level element. That is why the validator allows<p> tags inside of <form> tags, and why the <lable> tag requires a block level tag around it. It is not overkill, it is proper markup.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Frankly I really don't care if a page fails validation because I am using a target attribute in an a tag. KISS
User avatar
Chris Corbyn
Breakbeat Nuttzer
Posts: 13098
Joined: Wed Mar 24, 2004 7:57 am
Location: Melbourne, Australia

Post by Chris Corbyn »

astions wrote:Frankly I really don't care if a page fails validation because I am using a target attribute in an a tag. KISS
It's to do with specifications. If you tell the browser it's XHTML 1.1 when actually it's HTML 4.0 how can you expect the browser to render it correctly? It's like sticking ASP code in PHP tags and expecting the server to pick up on the fact it's not really PHP and parse it as ASP.

Not everything is related to accessibility... there are other reasons for validating code. It *should* bother you if your code does not validate... you cannot complain if some obscure browser does not display your page correctly if you've knowingly defined the wrong doctype.
User avatar
Benjamin
Site Administrator
Posts: 6935
Joined: Sun May 19, 2002 10:24 pm

Post by Benjamin »

Well I've read arguments going both ways on that one. I don't want to take this off topic though. Let me see if I can dig up some of the things I read and I'll make a new post.
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Re: Almost done :)

Post by Oren »

Hockey wrote:One, is that <A> doesn't support target="_blank"??? WTF how am I supposed to open links in new windows???
You are not supposed to :wink:
Everybody hates new windows.
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Post by matthijs »

Everybody hates new windows.
me too :x
Just tell your client opening windows is old-fashioned. I estimate that 3/4 of my clients have brought forward that links should open in new windows. So far, I have been able to convince all of them we shouldn't do it :)
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Post by Oren »

matthijs wrote:me too :x
Just tell your client opening windows is old-fashioned. I estimate that 3/4 of my clients have brought forward that links should open in new windows. So far, I have been able to convince all of them we shouldn't do it :)
Good job matthijs, that's cool 8)
Post Reply