Forum Moderators: open

Message Too Old, No Replies

trying to validate xhtml 1.0

one problematic line...

         

HelenDev

10:13 am on Oct 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member




<input name="search" id="search" value="search this site" size="15" onFocus="if(this.value=='search this site')this.value='';" />

Can anyone tell me why this line is not valid and what I can do about it?

thanks,
Helen.

benihana

10:20 am on Oct 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



is it xhtml strict?

what errors are being reported?

i think in strict you need to change onFocus to onfocus.

ta
ben

HelenDev

10:32 am on Oct 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Cheers Ben.

It isn't strict but changing it to onfocus does work.

But how come the js still works here? I thought js was case sensitive?

encyclo

1:35 pm on Oct 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



But how come the js still works here? I thought js was case sensitive?

Browsers are not validating parsers, so the only thing they use the doctype for is for switching between quirks and standards-compliance modes. For rendering the page, the browser uses its own internal DTD, dependent solely on mime-type.

If you serve XHTML as

text/html
(which virtually everybody does), the browser treats it no differently from plain HTML, including case-insensitive markup, depreciated elements, non-standard elements... The DTD specified in the doctype is ignored completely in all cases, and never even downloaded.

So the short of it is that errors of this type only matter to the validator, not to the browser. More serious errors, such as improper nesting, not only fail validation but can also have repercussions in the browser.

gohankid77

3:05 pm on Oct 12, 2004 (gmt 0)

10+ Year Member



As far as I know, the Moz family of browsers requires a ".xhtml" extension to recognize the document as XHTML locally. When running a server, you can just tell the browser to send it as "application/xhtml+xml" rather than "text/html".

HelenDev

3:26 pm on Oct 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



OK, but I was just wondering how come my javascript on the page still works when I have changed onFocus to onfocus?

Also, I now have another problem with this bit of code now in that in ie5 only, the submit button insists on being on the line below, and I want the search box and submit button to sit next to each other. Here is the code:


<input name="search" id="search" value="search this site" size="15" onfocus="if(this.value=='search this site')this.value='';" />
<input name="Submit" type="submit" value="go" class="quicklinksbutton"/>

I've tried using css to solve the problem but to no avail...


.searchform{
width:25%;
display:inline;
background-color: #daf2e6;
}


.searchform input{
border: 1px solid #009966;
display:inline;
}

works fine in moz and other versions of ie

gohankid77

3:40 pm on Oct 12, 2004 (gmt 0)

10+ Year Member



You are right. JavaScript is case-sensitive. Events call scripts, but are actually (X)HTML attributes.

As for the IE5 problem, I can't test it since I don't have that browser. Sorry.

HelenDev

3:51 pm on Oct 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Events call scripts, but are actually (X)HTML attributes

Aha. I see now. Thank you :)

Maybe I'll post my ie5 question in a new topic.

kaled

10:55 pm on Oct 12, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Javascript is case sensitive, however, I believe that all standard event names are case-insensitive. Not sure how they bodged this but you could equally use ONFOCUS or onFOCus.

I haven't used XHTML but I think it specifies that all tags and attributes must be lower case - hence the validation error.

Kaled.

gohankid77

2:37 am on Oct 13, 2004 (gmt 0)

10+ Year Member



I haven't used XHTML but I think it specifies that all tags and attributes must be lower case - hence the validation error.

That is correct. XML is case-sensitive, and XHTML is "A Reformulation of HTML 4 in XML 1.0" (XHTML 1.0 front page at w3.org). Therefore, XHTML attributes and values must all be lowercase to make debugging code easier.

@kaled: You should consider looking into XHTML. After all, version 2.0 is on its way already! The W3C is just working out the DTD, namespaces, and bugs, and is also taking into consideration the opinions of those concerned about the future of Web authoring. It may be a while, so until it comes out, you should check into XHTML 1.0 at least. Maybe move to XHTML 1.0 Transitional first which is HTML 4 Transitional with everything lowercase and all tags closed (basically).

kaled

10:08 am on Oct 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I've been working on a major site overhaul in the last few weeks and, amongst other things, all tags are now lower case and closed (where this was optional before).

I do plan to look at XHTML but I don't think I'll have time for this before Christmas. I maintain a website out of necessity rather than choice.

Kaled.

PS
Am I correct in thinking that XML is basically a freeform tag system for describing data in heirarchies? I am planning to move data storage from the Windows registry into a text file shortly and was planning to make it look like XML and possibly use the file extension .XML - Ideally I would like to make it valid XML but so far, all I know about it I've learnt from glancing at XML files.

gohankid77

3:31 pm on Oct 13, 2004 (gmt 0)

10+ Year Member



@kaled:
In order for something to be "valid" XML, you would need to create a DOCTYPE that specifies all of your tags and what can be contained inside them for the W3C validator to see it as valid.... Too much work basically. Leave the DOCTYPE thing out of the XML file, make sure all of your tags and attributes are lowercase, and you have a valid XML file! If you want to talk about this more, I'd ask an XML expert. I've only played around with it, so I don't have any reliable experience.

kaled

3:55 pm on Oct 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Thanks - that's pretty much what I thought but it's nice to see it confirmed.

Kaled.

Bonusbana

4:10 pm on Oct 13, 2004 (gmt 0)

10+ Year Member



HelenDev,

If you want to play by the strict rules of web standards, you really should put all your JavaScript in an external file and leave the markup alone. Your example could easily be replaced with external DOM javascripts, that could parse your markup upon window load and do the things you want it to do.

kaled

6:34 pm on Oct 13, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I place shared javascript in external files and embed unique javascript in the HTML normally. Embedding javascript code will make the page slightly faster to load. If you remember to place HTML comments around the code, there really should not be any conflict whatsoever with standards.

Granted, I'm working with HTML 4.01 Trans, but I validated such a page about five minutes ago.

Kaled.