Head Order

S

shapper

Hello,

In a page Head is there an order that should be used? I am using the
following:

<head id="head">

<title>Page Title</title>
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
<meta name="description" content="My Company web site" />
<meta name="keywords" content="new york, paris, cars" />

<link href="../../Assets/Style/PT/Site.css" rel="stylesheet"
type="text/css" />

<script src="../../Assets/Script/Library/JQuery/Site.js" type="text/
javascript"></script>

</head>

Is this ok?

If <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" /> is the first item before the title or after the
title and all meta's is there a problem?

Thanks,
Miguel
 
S

shapper

In general, no. But, there are a few exceptions; in CSS, for example, if
the specificity of two rules are otherwise the same, then whatever rule
appeared last will "win."


There is a problem here, but not the one you think. Listing the content
type in a meta element can be useful for local browsing of file: URLs,
but when pages are served over the web, the real HTTP header takes
precedence over it. So if your web server is configured to serve
everything as UTF-8, the above meta element will be ignored and browsers
will interpret your page as UTF-8.

sherm--

I see ... I am using iso-8859-1 because I think since I use some
characters on my text as ç, á, ... I needed to use it.

However, I am not completly sure ... I don't complete understand this.

But going back can I place

<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />

at start, before the title or at end, after the script?

I am asking this because I am generating this code line on server.

Thanks,
Miguel
 
S

shapper

That's not the only charset which includes those characters. You need to
use - in HTTP headers - whatever charset your page is actually using.



Don't - you need to study and understand this. Ignoring it won't make it
go away.

If your page really uses ISO-8859-1, then your server must be sending
that *in the HTTP headers* for your page to work. If your page is *not*
using ISO-8859-1, then adding a meta element will not magically make it
so. Nor will adding a meta element override what the server is sending
in the HTTP headers - no matter where in the head you put it.

Where's the page you're having trouble with? URL please.

sherm--

At the moment the page is only in my computer. I am using the new
ASP.NET MVC.

So I need to know what the server is sending ... Is this dependent of
the server or maybe of the ASP.NET Framework?

How can I check this? Maybe I should post on the ASP.NET MVC forum?

Thanks,
Miguel
 
S

shapper

Both, or either. Ask not the elves for advice... :)

Any server will have a default. But any server can also be configured to
send any content-type header, and any dynamic content generation tool
can also send whatever HTTP headers it wants to.


If you don't know what HTTP headers are sent by ASP.NET by default, or
how to change what headers it sends, then yes - that's probably a good
place to ask about that.

sherm--

Dah, I knew this along time ago but I forgot that I knew it! :)

In ASP.NET there is a Web.config file where the encoding can be for
the application:

<configuration>
<system.web>
<globalization
fileEncoding="utf-8"
requestEncoding="utf-8"
responseEncoding="utf-8"
/>
</system.web>
</configuration>

And that means:

requestEncoding
Specifies the expected encoding type for incoming requests including
post and querystring data. This value can be overridden by the Accept-
Charset value of the request header.By default this value is set to
UTF-8.

responseEncoding
Specifies the type of encoding to use when responding to requests. The
default value is UTF-8.

fileEncoding
Specifies the type of encoding of the various ASP.NET file types
including .aspx, .asmx, and .asax.

Now this said, when should I use iso-8859-1 instead of UTF-8? When my
web site displays characters as ç, á, à, ...

I am asking this because in the past I had problems with this where ç,
à, á and so on are replaced by a question mark.

Thanks,
Miguel
 
L

Lars Eighner

In our last episode,
<f628d142-1092-4aba-8588-7d8e901a59a3@m44g2000hsc.googlegroups.com>,
the lovely and talented shapper
broadcast on alt.html:
I see ... I am using iso-8859-1 because I think since I use some
characters on my text as ç, á, ... I needed to use it.
However, I am not completly sure ... I don't complete understand this.
But going back can I place
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />
at start, before the title or at end, after the script?

No. This header is useless. You must adjust the http headers that
are actually served. Consult your server documentation. If your server is
Apache, you can make the adjustment with .htaccess (if the admin permits
it). Some other servers use .htaccess but syntax of directives may vary.
I am asking this because I am generating this code line on server.

This makes no sense.
 
N

Neredbojias

In general, no. But, there are a few exceptions; in CSS, for example, if
the specificity of two rules are otherwise the same, then whatever rule
appeared last will "win."


There is a problem here, but not the one you think. Listing the content
type in a meta element can be useful for local browsing of file: URLs,
but when pages are served over the web, the real HTTP header takes
precedence over it. So if your web server is configured to serve
everything as UTF-8, the above meta element will be ignored and browsers
will interpret your page as UTF-8.

And if it is not configured to serve anything and there is no header sent,
it's a good bet the http-equiv will prevail.
 
A

Adrienne Boswell

Gazing into my crystal ball I observed shapper <[email protected]>
writing in @d45g2000hsc.googlegroups.com:
Hello,

In a page Head is there an order that should be used? I am using the
following:

<head id="head">

<title>Page Title</title>

The page title must reflect the content of the page, eg:
<meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" />

See what others have said in this thread. The server will override
this.
<meta name="description" content="My Company web site" />

Again, this should reflect the contents of the page, eg. <meta
name="description" content="Maine Coon cats, information and history of
the oldest natural breed in America"
<meta name="keywords" content="new york, paris, cars" />

Keywords should also reflect the content of the page. The keywords
above seem jumbled, and have nothing to do with each other. New York
and Paris are known for fashion, not cars. If you said "Detroit,
France, Japan, cars" that would make more sense.
<link href="../../Assets/Style/PT/Site.css" rel="stylesheet"
type="text/css" />

<script src="../../Assets/Script/Library/JQuery/Site.js" type="text/
javascript"></script>

Be careful with this, especially if the production server does not allow
parent paths. You might be okay with HTML markup, but using an include,
or opening a file in a parent directory could cause problems.
</head>

Is this ok?

If <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" /> is the first item before the title or after the
title and all meta's is there a problem?

Again, the server will override the meta element. With that being said,
if there is no server available, you might want to put the title after
that meta element if there are special characters in the title element.
 
H

Harlan Messinger

Ben said:
And except for script elements-- they get executed in the order they
appear.


Yes, although those meta tags can be quite useful if you're testing
things with file:// urls.

And they're useful for people who save pages locally.
 
L

Lars Eighner

In our last episode,
<[email protected]>,
the lovely and talented Harlan Messinger
broadcast on alt.html:
And they're useful for people who save pages locally.

Curious. My browser adds them at the top on saves whether they are any in
the document or not.
 
H

Harlan Messinger

Lars said:
In our last episode,
<[email protected]>,
the lovely and talented Harlan Messinger
broadcast on alt.html:
Ben said:
[...]
The order of header elements is immaterial except for stylesheet links,
because order counts in the cascade.
And except for script elements-- they get executed in the order they
appear.

If <meta http-equiv="Content-Type" content="text/html;
charset=iso-8859-1" /> is the first item before the title or after the
title and all meta's is there a problem?
The problem is that this header is useless. If your server is sending the
wrong http headers, you need to get it to send the right ones.
Yes, although those meta tags can be quite useful if you're testing
things with file:// urls.
And they're useful for people who save pages locally.

Curious. My browser adds them at the top on saves whether they are any in
the document or not.

Ah, OK, that hadn't occurred to me. That's even better, of course,
assuming the one added by the browser corresponds to the header sent by
the server. But--you're saying that even if the page already has one,
the browser adds another--so that there are two of them? I wonder what
happens if the one that's already in the document doesn't match the one
sent by the server: does the browser replace it with the correct one?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,071
Latest member
MetabolicSolutionsKeto

Latest Threads

Top