18 replies [Last post]
vdonatiello
Offline
Regular
nanning - china
Last seen: 10 years 25 weeks ago
nanning - china
Timezone: GMT+8
Joined: 2003-10-26
Posts: 12
Points: 0

i am stuck at this error which i don't understand ..

this page http://www.donatiello.info/ says

Quote:
No error or warning found
Congratulations!
This document validates as CSS!

this is the beginning of the code where the prolog suppose to be ..
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>
<head>
<title>Vito Donatiello home page</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />

<link rel="stylesheet" type="text/css" href="style/home.css" />

<script type="text/javascript">
.....
<!--

here is another page at http://www.donatiello.info/spammer.html and the validator returns

Quote:
Target: http://www.donatiello.info/spammer.html
Please, validate your XML document first!
Line 1
Column 1
Content is not allowed in prolog

but the code is almost the same ..

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<html>
<head>
<title>Spammer are not welcome here :: www.donatiello.info</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<style type="text/css">
body {
.....

could anyone help, i am confused as i don't use any prolog and the doctype doesn't ask for XML ..

thanks a lot, vito

Chris..S
Chris..S's picture
Offline
Moderator
Last seen: 1 year 30 weeks ago
Timezone: GMT+1
Joined: 2005-02-22
Posts: 6078
Points: 173

Content is not allowed in prolog

that page validates for me.

Anonymous
Anonymous's picture
Guru

Content is not allowed in prolog

Chris..S wrote:
that page validates for me.
try the CSS validator.

I am sure the css-validator only works for .css files and not for embedded css contained in the style tags. That could be your problem. Smile

(hheight is not a property. Wink)

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 10 hours 26 min ago
Dallas
Timezone: GMT-5
Joined: 2004-06-25
Posts: 9053
Points: 3022

Content is not allowed in prolog

In Firefox Web Developer⇒Tools⇒Validate Local CSS, the embedded css will be pasted into the validator textarea.

cheers,

gary

Unplanned code results in a tangled wad of brain-cramping confusion.

There are enough html & css demos and tutorials to be interesting. Please visit.

vdonatiello
Offline
Regular
nanning - china
Last seen: 10 years 25 weeks ago
nanning - china
Timezone: GMT+8
Joined: 2003-10-26
Posts: 12
Points: 0

Content is not allowed in prolog

hello chris,

thanks for your answer .. i did double check the validator doesn't work with embedded style Sad

then i changed the file, i made a .ccs file and i put a link in the head of spammer.html .. here is what happen:
- if i try to validate the .css it says OK
- but it i try to validate the spammer.html it says

Quote:

Target: http://www.donatiello.info/spammer.html
Please, validate your XML document first!
Line 1
Column 1
Content is not allowed in prolog.

so i don't know what is wrong?????

here is the html file: http://www.donatiello.info/spammer.html which doesn't validate

here is the css file: http://www.donatiello.info/style/spammer.css which validate OK

thanks for your time, vito

Chris..S
Chris..S's picture
Offline
Moderator
Last seen: 1 year 30 weeks ago
Timezone: GMT+1
Joined: 2005-02-22
Posts: 6078
Points: 173

Content is not allowed in prolog

Very odd.

I made a copy of your page with one change, full url for the stylesheet (to get it from your site). It validates ok.

vdonatiello
Offline
Regular
nanning - china
Last seen: 10 years 25 weeks ago
nanning - china
Timezone: GMT+8
Joined: 2003-10-26
Posts: 12
Points: 0

Content is not allowed in prolog

hi again chris,
i want to cry Evil
i did try to apply the same change as you (absolute url) for the stylesheet link .. but without luck
does it have to do with the doctype or charset??? i don't have a clue cause it say at line 1 column 1 ..

thanks again, vito

Chris..S
Chris..S's picture
Offline
Moderator
Last seen: 1 year 30 weeks ago
Timezone: GMT+1
Joined: 2005-02-22
Posts: 6078
Points: 173

Content is not allowed in prolog

I didn't think the change would be important, was just trying to say the page was essentially the same.

What that means ... there is nothing wrong with your page. The problem is either
- something to do with your webserver
- there is some wierd invisible character in your web page

Try
- using my copy of the page (since we know that validates), ie. view the source, select all, copy and paste it into a page on your website.
- recreating your page via copy paste
- recreating your page by hand

rmfred
Offline
Elder
Rock Springs, WY
Last seen: 1 year 25 weeks ago
Rock Springs, WY
Timezone: GMT-6
Joined: 2004-01-31
Posts: 1073
Points: 31

Content is not allowed in prolog

Quote:
so i don't know what is wrong?????

here is the html file: http://www.donatiello.info/spammer.html which doesn't validate

I just tried that page and it validated...
http://validator.w3.org/check?verbose=1&uri=http%3A//www.donatiello.info/spammer.html

www.powerbitwebdesign.com Powerbit your custom web design company

Chris..S
Chris..S's picture
Offline
Moderator
Last seen: 1 year 30 weeks ago
Timezone: GMT+1
Joined: 2005-02-22
Posts: 6078
Points: 173

Content is not allowed in prolog

its the CSS check that fails.

vdonatiello
Offline
Regular
nanning - china
Last seen: 10 years 25 weeks ago
nanning - china
Timezone: GMT+8
Joined: 2003-10-26
Posts: 12
Points: 0

Content is not allowed in prolog

hi chris,

Quote:
Try
- using my copy of the page (since we know that validates), ie. view the source, select all, copy and paste it into a page on your website

i did it and it works! then i tried different to spot the trouble .. maybe i have figured out, maybe i am stupid .. i am using ms notepad, copy and save the file, you know you have 3 options: name, save as, and code (not sure as i have an italian version) .. well last one i guess is the one i mess up .. in the html i used the meta tag to declare charset utf-8 .. so i did with the last option of the notepad editor, but maybe it introduced some extra characters .. then i tried to save with the notepad as ANSI code, uploaded and it DID work ..
i don't know if you or someone else if very knowledgeable about charset .. i always used utf-8, i always save my html file with notepad utf-8 code .. it had always worked so far .. maybe it is a validator problem .. does anyone advice me to save as ANSI instead utf-8 (even thought i choosed utf-8 as a charset in the meta tag) .. don't knwo, right now i am confused ..
however thanks a lot for assisting me during this hassle
vito

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 14 weeks 4 days ago
London
Joined: 2004-06-06
Posts: 15650
Points: 2788

Content is not allowed in prolog

Ms Notepad puts a 3 byte sequence at the beginning of the file if saved as utf-8 which isn't great if you are saving a document with a DTD as you do not want any characters before the DTD, as you wouldn't if it were a php file with a session_start () you would probably get a headers already sent warning then.

This is probably a good reason not to use Notepad, although I do from time to time with no problem but then I usually use iso-8859-1 encoding, as I'm not sure whether utf-8 is 100.1% accepted yet.

Hugo.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

vdonatiello
Offline
Regular
nanning - china
Last seen: 10 years 25 weeks ago
nanning - china
Timezone: GMT+8
Joined: 2003-10-26
Posts: 12
Points: 0

Content is not allowed in prolog

thanks for sharing Hugo,

i know we are going off topic .. but if you could tell me i would appreciate it:

- how do you know ms notepad adds 3 extra characters at the very begginning of the file, which editor or tool do you use to see that

- then, it is convenient to use notepad for small editing on html file, so should i save as ANSI insted???

- i will stick with charset utf-8 .. before i lived 2 years in china and it was such a mess between western and chinese characters .. iso is the largest so far, but utf-8 suppose to be future most supported charset, as far as i read several months ago when i decided to publish all the webpages as utf-8

thanks again

Hugo
Hugo's picture
Offline
Moderator
London
Last seen: 14 weeks 4 days ago
London
Joined: 2004-06-06
Posts: 15650
Points: 2788

Content is not allowed in prolog

I had a similar problem a while back but the details are foggy but I was getting told that I had characters at the begining of the document, when I knew there weren't any. I opened the file in a proper editor (tsWebEditor) and lo and behold these were sitting in front of the DTD



I take your point about using UTF-8, it's just that at one time it was still waiting to become universally accepted.

I would just avoid using Notepad basically, maybe download a copy of tsWebEditor or and to make Gary happy Smile a copy of the renowned and oft mentioned Emacs which people in the know seem to use Wink
But if you do have to use Notepad save as ANSI I always do and seem to have no problems.

Before you make your first post it is vital that you READ THE POSTING GUIDELINES!
----------------------------------------------------------------
Please post ALL your code - both CSS & HTML - in [code] tags
Please validate and ensure you have included a full Doctype before posting.
Why validate? Read Me

vdonatiello
Offline
Regular
nanning - china
Last seen: 10 years 25 weeks ago
nanning - china
Timezone: GMT+8
Joined: 2003-10-26
Posts: 12
Points: 0

Content is not allowed in prolog

thanks Hugo
i downloaded tsWebEditor, play a little with it, seems nice
again it was a very odd problem, i used for 2 years to save my html file with notepad just because it was the only one i knew to be able to save as utf-8 code, then ftp and everything worked fine .. i also have to admit that i don't validate all the time .. or maybe it was becuase i was using a chinese computer with charset on the machine itself .. i don't know but i thought that was the wasy to go .. my from my laptop i need to save as ANSI to be sure ..
thanks anyway
vito

vdonatiello
Offline
Regular
nanning - china
Last seen: 10 years 25 weeks ago
nanning - china
Timezone: GMT+8
Joined: 2003-10-26
Posts: 12
Points: 0

Content is not allowed in prolog

Triumph wrote:

I am sure the css-validator only works for .css files and not for embedded css contained in the style tags.

hello chris,
how weird, i was trying to make a template and this time it DID validated embedded css
http://www.donatiello.info/minimal.htm

just for reference

best, vito

KayEss
KayEss's picture
Offline
Regular
Bangkok
Last seen: 7 years 2 days ago
Bangkok
Timezone: GMT+7
Joined: 2005-04-03
Posts: 26
Points: 0

unless

Hugo wrote:
Ms Notepad puts a 3 byte sequence at the beginning of the file if saved as utf-8 which isn't great if you are saving a document with a DTD as you do not want any characters before the DTD.

The three bytes are the BOM (Byte Order Mark) and is part of the Unicode specifications for all of the UTF encodings. Notepad's use of the BOM in this situation is absolutely 100% standards conformant - any software that says it is Unicode compatible and doesn't understand the BOM is broken.

If this is what's causing the validation error then I should think that the validator is to blame unless your server is telling it a different character encoding in the headers, in which case your server is wrong. If the server gives a different encoding in the headers then the validor must interpret those three bytes as character data in which case it will correctly fail validation.

You really oughtn't to save as ASCII and then put the utf-8 meta tag in the file though.

This is the Unicode FAQ on BOM: http://www.unicode.org/faq/utf_bom.html#BOM

The UTF-8 RFC: http://www.faqs.org/rfcs/rfc3629.html[/b]

vdonatiello
Offline
Regular
nanning - china
Last seen: 10 years 25 weeks ago
nanning - china
Timezone: GMT+8
Joined: 2003-10-26
Posts: 12
Points: 0

Content is not allowed in prolog

hello KayEss,

thanks for your explanation, it is very accurate ..

i don't think it is a validator fault .. how could i check the server encoding header? as many i share a server in a webhotel .. is there any way to check it out?

Quote:
You really oughtn't to save as ASCII and then put the utf-8 meta tag in the file though.

i thought and read ms notepad was a neat editor, often i use some other editor with highlight code functions and so on, then i copy and paste on notepad and all the extra spaces .. save as utf-8 (which is my choosen encoding) and upload it ..
in these posts seems it seems that is not a good way to go and it will be better to use and save html file with other editors in order to avoid these three bytes as character data placed at the very beginning .. what's is your opinion then?

thanks for taking the time to share,

vito

KayEss
KayEss's picture
Offline
Regular
Bangkok
Last seen: 7 years 2 days ago
Bangkok
Timezone: GMT+7
Joined: 2005-04-03
Posts: 26
Points: 0

Content is not allowed in prolog

No problems. I did find a site for returning headers, I'll have to chase the link (see below).

If your server is broken (it should either spot the BOM and set the encoding in a proper header and then strip it, or it shouldn't send any character encoding header) and there isn't anything you can do about it then you ought to save your files with whatever character encoding the server seems to default to.

If the validator seems to be broken then I should ignore the error - the document is actually fine. You could try to run it through a second online validator and see if that produces the same error.

This should give you some details about what's going on: http://www.clanproductions.com/headers_display.html

Running that on http://www.donatiello.info/spammer.html there wasn't any character encoding in the server's headers. Assuming that the validator is getting the file from HTTP then I think that the validator is broken.

If the validator is getting the file from a file upload then it's a slightly different matter. That would then depend on how the file is being uploaded (the form method as well as the character encoding of the file that the upload form is in). This is where it all gets very hairy.

To be honest, the BOM's presence is fine on a HTML page, and for XML is generally required (there are other considerations though).

Hope this doesn't just confuse you further Wink