HTML and CSS Reference
In-Depth Information
Most people would agree that using the UTF-8 character set is probably a good idea for
Western-language page authors because it gives them access to international character
glyphs when needed without causing them any trouble:
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
Deciding which MIME type to use isn't as straightforward. For standard HTML, the
MIME type is always text/html . However, when XHTML is in play, confusion and
browser problems ensue. Numerous pundits bemoan the fact that most XHTML is served as
text/html , particularly because it doesn't give you the strict parsing that XML tends to
afford. In the use of XHTML, you may choose from text/html , text/xml , application/
xml , and application/xhtml+xml as potential MIME types. Given the potential for
compatibility and even rendering problems, for better or worse, the MIME type text/html
will be used for nearly all (X)HTML examples in this topic so that browser rendering is
ensured. This hedge will be explored a bit more later in the chapter when addressing the
implications of XHTML. In summary at the point of writing this edition, it is recommend
specifying a Content-Type of text/html and the UTF-8 character set, and doing so as
your first element within the head, like so:
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" >
<title> Page title here </title>
</head>
N OTE The meta element also has many other uses beyond defining character set and MIME type.
It is also used to set arbitrary name-content pairs to provide meta-information about a document
for purposes like search engine optimization (for example, <meta name="keywords"
content="Keyword1 , ...Keyword N" > ). Other uses of <meta> tags will be covered in
the reference section of Chapter 3.
Other Elements in the head
In addition to the title and meta elements, under the HTML 4.01 and XHTML 1.0 strict
DTDs, the elements allowed within the head element include base , link , object , script ,
and style . Comments are also allowed. A brief discussion of the other head elements and
comments follows. Complete information is available in the element reference found in
Chapter 3.
<base> A <base> tag specifies an absolute URL address that is used to provide server
and directory information for partially specified URL addresses, called relative links , used
within the document:
<base href="http://htmlref.com/basexeample" >
Because of its global nature, a <base> tag is often found right after a <title> tag as it
may affect subsequent <script> , <link> , <style> , and <object> tag referenced URIs.
Search WWH ::




Custom Search