Your Ad Here

Setting Content Types Server-Side


The HTTP-equivalent meta tag does the job of setting a page’s content type, but
if at all possible it is preferable to use a genuine HTTP header. With the meta
tag, the browser must receive the HTML file and then decipher the content type,
but by establishing the content type on the server side before the HTML file is
sent, the browser will be told what to expect beforehand.
One way of sending the content type is by using a server-side scripting language
such as PHP:

<? header(“Content-Type: text/html; charset= UTF-8”); ?>

If you don’t want to (or can’t) use a server-side scripting language, you might be
able to go straight to the server with an “.htaccess” file. Most servers (Apache
compatible) can have a small text file with the file name “.htaccess” that sits in
the root directory and with the following line in it, you can associate all files with
the extension “.html” with a MIME type and character set:
AddType text/html;charset=UTF-8 html

0 comments:

Post a Comment

Popular Posts

Recent posts