Click here to get back home

@charset rule

 HomeNewsGroups | Search | About
 comp.infosystems.www.authoring.html    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
@charset rule =?ISO-8859-1?Q?Fran=E7ois_Patt 10-06-2007
|--> Re: @charset rule André Gillibert10-06-2007
---> Re: @charset rule Harlan Messinge...10-06-2007
  ---> Re: @charset rule =?ISO-8859-1?Q?...10-06-2007
  | |--> Re: @charset rule Harlan Messinge...10-06-2007
  | `--> Re: @charset rule Jukka K. Korpel...10-06-2007
  `--> Re: @charset rule =?ISO-8859-1?Q?...10-07-2007
Posted by Harlan Messinger on October 6, 2007, 10:43 am
Please log in for more thread options
François Patte wrote:
> Harlan Messinger a écrit :
>> François Patte wrote:
>>> Bonjour,
>>>
>>> I am wondering why the @charset rule is not working for me.
>>>
>>> I put at the early beginning of my index.css file:
>>>
>>> @charset "utf-8";
>>>
>>> no line before....
>>>
>>> and in every html file:
>>>
>>> <link rel="STYLESHEET" href="index.css">
>>>
>>> Everything is OK for all style definitions made in the index.css
>>> (background, fonts style, size, and so on....
>>>
>>> Only the charset definition is not working.... Browsers always return
>>> ISO8859-1!!!
>> The @charset rule specifies only the encoding of the stylesheet. It
>> doesn't specify the encoding of the web page that links to the
>> stylesheet. It can't--the page's content can be completely processed and
>> the document model completely built in memory by the time the stylesheet
>> gets to the browser.
>
> Thanks to all. I did not understand that this declaration was limited to
> the css file only...
>
> And now I don't understand why it is necessary to declare the charset of
> the css file.

It *isn't* necessary unless (a) the server isn't sending a charset
parameter in a Content-Type header (because if the server is sending
one, then the @charset rule will be ignored anyway) and (b) the wrong
encoding would be applied following application of items 3 through 5
below, in order by priority from highest to lowest.

[Steps for determining the encoding of an external CSS sheet, from
http://www.w3.org/TR/CSS21/syndata.html#charset]

1. An HTTP "charset" parameter in a "Content-Type" field (or similar
parameters in other protocols)
2. BOM and/or @charset (see below)
3. <link charset=""> or other metadata from the linking mechanism
(if any)
4. charset of referring style sheet or document (if any)
5. Assume UTF-8

Posted by Jukka K. Korpela on October 6, 2007, 3:05 pm
Please log in for more thread options
Scripsit François Patte:

> I did not understand that this declaration was limited
> to the css file only...

That's not surprising; virtually all people get very confused with charset
issues when they start working with them, but we can learn to keep the
confusion at a manageable level.

> And now I don't understand why it is necessary to declare the charset
> of the css file.

Mostly it isn't. You normally use just ASCII characters there, and then the
charset mostly does not matter.

It matters if you use, say, a font name containing non-ASCII characters,
like

body { font-family: "François", sans-serif; }

(just assuming that you expect a font called "François" to exist somewhere).
People have used e.g. font names containing Japanese characters.

If this still puzzles you, c.i.w.a.stylesheets would be the right group to
ask about CSS issues.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/


Posted by =?ISO-8859-1?Q?Fran=E7ois_Patt on October 7, 2007, 4:11 pm
Please log in for more thread options
Jukka K. Korpela a écrit :
> Scripsit François Patte:
>
>> I did not understand that this declaration was limited
>> to the css file only...
>
> That's not surprising; virtually all people get very confused with
> charset issues when they start working with them, but we can learn to
> keep the confusion at a manageable level.
>
>> And now I don't understand why it is necessary to declare the charset
>> of the css file.
>
> Mostly it isn't. You normally use just ASCII characters there, and then
> the charset mostly does not matter.
>
> It matters if you use, say, a font name containing non-ASCII characters,
> like
>
> body { font-family: "François", sans-serif; }
>
> (just assuming that you expect a font called "François" to exist
> somewhere). People have used e.g. font names containing Japanese
> characters.
>
> If this still puzzles you, c.i.w.a.stylesheets would be the right group
> to ask about CSS issues.

Thanks for this clarification and for the address.

--
François Patte
Université Paris 5 - Paris

Similar ThreadsPosted
Charset Mismatch November 7, 2004, 10:13 am
ISO CHARSET PROBLEM November 8, 2005, 10:13 am
Server handling of Charset August 1, 2004, 1:15 pm
charset=unknown-8bit October 18, 2005, 4:33 pm
About charset setting and replacing July 14, 2006, 6:29 am
Setting Correct Charset? June 29, 2007, 10:24 am
Tech guy still insists the problem is charset October 29, 2004, 4:29 am
Netscape Composer: How to set charset for a page? November 4, 2004, 6:11 am
browsers don't follow the charset specification March 10, 2005, 10:19 am
Determining Charset used by system or software January 19, 2006, 2:03 pm

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap