Page 1 of 1 [ 16 posts ] 

jimmister
Raven
Raven

User avatar

Joined: 4 Oct 2008
Age: 34
Gender: Male
Posts: 104

30 Nov 2008, 3:34 pm

Hello. I am a beginner learner learning from a book about using Javascript. I follow all the steps to make sure all the markup is right, but the W3C says otherwise. Can anyone tell me ay changes that happened in markup. I got busted by the W3C validator for using the <p> code.



sanndr
Blue Jay
Blue Jay

User avatar

Joined: 25 Nov 2008
Age: 50
Gender: Male
Posts: 89

30 Nov 2008, 4:16 pm

Note: I had to omit the script-tags in the code sections as the site didn't like me using the script-tags.

It's very hard to see what the W3C validator borked about without seeing the actual code you sent it, and which HTML-version you told it you were using.

Going out on a limb (and hoping that I'm correct) the complaint from the validator is probably due to the use of full tags withing the javascript tags.

Something like:

Code:
  document.write('<p>Validation error</p>');


In older browsers that that didn't understand the script-tag it was circumvented with:
Code:
<!--
  document.write('<p>Remember Netscape 4?</p>');
// -->


For the W3C validator try:
Code:
//<![CDATA[
  document.write('<p>welcome to the validators and xhtml</p>');
//]]>


WHen i started learning I found this site to be an invaluable resource: http://www.w3schools.com

Hope i understood your problem correctly :?



t0
Veteran
Veteran

User avatar

Joined: 23 Mar 2008
Age: 52
Gender: Male
Posts: 726
Location: The 4 Corners of the 4th Dimension

30 Nov 2008, 4:16 pm

<p> is an HTML tag for paragraph. It has nothing to do with Javascript.

It's hard to know what your problem is without seeing a sample of the code. In general, the paragraph should have an end tag (</p>).



lau
Veteran
Veteran

User avatar

Joined: 17 Jun 2006
Age: 77
Gender: Male
Posts: 9,798
Location: Somerset UK

30 Nov 2008, 4:20 pm

jimmister wrote:
Hello. I am a beginner learner learning from a book about using Javascript. I follow all the steps to make sure all the markup is right, but the W3C says otherwise. Can anyone tell me ay changes that happened in markup. I got busted by the W3C validator for using the <p> code.

Erm. <p> is [X]HTML markup, and has nothing to do with JavaScript. Maybe you could post the section of code you are having a problem with?

The only thing I can imagine that can go wrong with <p> is not closing it with </p>, or using it outside <body> </body>.


_________________
"Striking up conversations with strangers is an autistic person's version of extreme sports." Kamran Nazeer


Death_of_Pathos
Deinonychus
Deinonychus

User avatar

Joined: 7 Nov 2008
Age: 39
Gender: Male
Posts: 351

30 Nov 2008, 5:28 pm

lau wrote:
jimmister wrote:
Hello. I am a beginner learner learning from a book about using Javascript. I follow all the steps to make sure all the markup is right, but the W3C says otherwise. Can anyone tell me ay changes that happened in markup. I got busted by the W3C validator for using the <p> code.

Erm. <p> is [X]HTML markup, and has nothing to do with JavaScript. Maybe you could post the section of code you are having a problem with?

The only thing I can imagine that can go wrong with <p> is not closing it with </p>, or using it outside <body> </body>.


Haven't met a browser yet that gets upset when you don't close <P>.

But yeah, post the source and we'll rip it apart for you :wink:

W3C is good, its where I first learned. That and right click>view>source.



lau
Veteran
Veteran

User avatar

Joined: 17 Jun 2006
Age: 77
Gender: Male
Posts: 9,798
Location: Somerset UK

30 Nov 2008, 6:12 pm

Death_of_Pathos wrote:
...
Haven't met a browser yet that gets upset when you don't close <P>.
...

In HTML, the closing tags are often optional. The </p> is such an optional close.

In XHTML, all close tags are required.

One common mistake, when transitioning between HTML to XHTML is to get all confused about the break tag.

In HTML, there is no closing tag, and you just use <br>
In XHTML, the closing tag is required, and hence you (on the face of it) need <br> </br>
However, the shorthand form is permitted: <br/>
But then people start using this shorthand form in HTML, which is an error.

The problem with not following the strict rules is that each browser is then making a guess at what broken [X]HTML is attempting to do, and each browser is likely to differ in what guess it makes.

It is unfortunate that most browsers are incapable of showing you what "helpful corrections" they are making to website code, before they merrily display it, with whatever fudges they have applied to hide the bugs.


_________________
"Striking up conversations with strangers is an autistic person's version of extreme sports." Kamran Nazeer


Death_of_Pathos
Deinonychus
Deinonychus

User avatar

Joined: 7 Nov 2008
Age: 39
Gender: Male
Posts: 351

30 Nov 2008, 6:15 pm

True enough but Ive always been told that if you are moving to a rigid environment like xhtml you probably shouldnt be using <p> in the first place.



pakled
Veteran
Veteran

User avatar

Joined: 12 Nov 2007
Age: 68
Gender: Male
Posts: 7,015

30 Nov 2008, 7:00 pm

There's HTML/XML converters out there (even Front Page 2003 has them).

I don't know from Java, but if you could post the errors, there might be a little more help. Also, cut the error off of the screen (or type it into a browser), enclose the whole thing in double quotes, and search on that. It can find things a lot of the time (getting an answer for free, however....;)



jimmister
Raven
Raven

User avatar

Joined: 4 Oct 2008
Age: 34
Gender: Male
Posts: 104

01 Dec 2008, 12:19 pm

Why should validation matter? If the page renders fine, I'm fine.



t0
Veteran
Veteran

User avatar

Joined: 23 Mar 2008
Age: 52
Gender: Male
Posts: 726
Location: The 4 Corners of the 4th Dimension

01 Dec 2008, 12:53 pm

jimmister wrote:
Why should validation matter? If the page renders fine, I'm fine.


True to some extent. The problem is if the page displays correctly due to a bug in the browser. Then there's a decent chance it won't display correctly when the bug is fixed, or in other browsers that don't have the bug.

Personally, I don't validate my HTML because I don't work on anything that complicated. I also tend to indent as if I'm writing code, so it's a lot easier to read. If you're building complex pages (or you notice problems displaying the pages in some browsers) I could see where a validation would help.



Death_of_Pathos
Deinonychus
Deinonychus

User avatar

Joined: 7 Nov 2008
Age: 39
Gender: Male
Posts: 351

01 Dec 2008, 4:25 pm

jimmister wrote:
Why should validation matter? If the page renders fine, I'm fine.


Yeah I can't see myself validating to XHTML standards outside of A) school B) work.



lau
Veteran
Veteran

User avatar

Joined: 17 Jun 2006
Age: 77
Gender: Male
Posts: 9,798
Location: Somerset UK

01 Dec 2008, 4:32 pm

jimmister wrote:
Why should validation matter? If the page renders fine, I'm fine.

In which browser?
(And which version of that browser?)


_________________
"Striking up conversations with strangers is an autistic person's version of extreme sports." Kamran Nazeer


Death_of_Pathos
Deinonychus
Deinonychus

User avatar

Joined: 7 Nov 2008
Age: 39
Gender: Male
Posts: 351

01 Dec 2008, 4:44 pm

lau wrote:
jimmister wrote:
Why should validation matter? If the page renders fine, I'm fine.

In which browser?
(And which version of that browser?)


My standards on this, if I am going to be making something that the public at large should see, is that it should look good-enough (by whatever standard that is) on the most-recent Safari, Opera, Firefox, and IE.

Its a good question but honestly if you even try to make your code decent, without worrying about validation, achieving the above is dead simple on any but the most complex web page designs (which are, at that point, probably needlessly complex).



lau
Veteran
Veteran

User avatar

Joined: 17 Jun 2006
Age: 77
Gender: Male
Posts: 9,798
Location: Somerset UK

01 Dec 2008, 7:32 pm

I believe you are missing the point. If you try to adhere to the standards, and correct all errors reported by the validator, you may be confident that when you try your code out on various browsers (which is indeed precisely what you should do), any inconsistency is probably a quirk of that version of that browser.

You can then find some way to accommodate that, but without writing broken code.

The OP's remark: "I got busted by the W3C validator for using the <p> code", makes no sense to me. The validator isn't a policeman. It's a critic. If you write broken code, it tells you about it. It doesn't stop you writing bad markup.


_________________
"Striking up conversations with strangers is an autistic person's version of extreme sports." Kamran Nazeer


Death_of_Pathos
Deinonychus
Deinonychus

User avatar

Joined: 7 Nov 2008
Age: 39
Gender: Male
Posts: 351

02 Dec 2008, 11:13 pm

Your right of course. My inner-lazy-programmer got loose again.



lau
Veteran
Veteran

User avatar

Joined: 17 Jun 2006
Age: 77
Gender: Male
Posts: 9,798
Location: Somerset UK

03 Dec 2008, 12:07 pm

Death_of_Pathos wrote:
Your right of course. My inner-lazy-programmer got loose again.

Hey! You've got one of those too?


_________________
"Striking up conversations with strangers is an autistic person's version of extreme sports." Kamran Nazeer