Forum Moderators: mack

Message Too Old, No Replies

Code at the start of an HTML document

Code at the start of an HTML document

         

guitariststuff

4:13 pm on Nov 23, 2007 (gmt 0)

10+ Year Member



I am really stumped when it comes to the HTML at the start of my new document, ive got this bit which I know goes in: -

<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">

since I'm using HTML 4.

I am wondering what else I should put in? Do i put in

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

i know that i need to put in some meta http equiv thing but i just dont know what? i mean ive seen utf-8, iso-8859-1 and ive seen widowns 1252 or sumthin like that? what the hell does it all mean, i just want to make up an HTML webpage.... :-(

Can someone tell us what i need to stick in for it to be compliant!?

Cheers guys

kolin

4:19 pm on Nov 23, 2007 (gmt 0)

10+ Year Member




<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<link rel="stylesheet" href="/includes/css/site.css" type="text/css" />
<!--[if IE 7]>
<link rel="stylesheet" href="/includes/css/ie.css" type="text/css" />

<![endif]-->
<!--[if lte IE 6]>
<link rel="stylesheet" href="/includes/css/ie6.css" type="text/css" />
<![endif]-->
</head>

the above is the code i always use, any reason why you would use transitional over Strict?

kolin

4:21 pm on Nov 23, 2007 (gmt 0)

10+ Year Member



from wikipedia


UTF-8 (8-bit UCS/Unicode Transformation Format) is a variable-length character encoding for Unicode. It is able to represent any character in the Unicode standard, yet the initial encoding of byte codes and character assignments for UTF-8 is backwards compatible with ASCII. For these reasons, it is steadily becoming the preferred encoding for e-mail, web pages, and other places where characters are stored or streamed.

guitariststuff

5:01 pm on Nov 23, 2007 (gmt 0)

10+ Year Member



First of all i am using html 4.01 and not XHTML 1.0 therefore i cannot use the following doctype

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">

also, you use utf-8 however you are using xhtml so it may not be right for me? and i dont hav a clue what that wikipedia description is going on about!

i just want to learn basic html coding,but which is correct, i would like the bit which is to go before the body cos i dont understand any of it. can anyone help please?

Thanks!

piatkow

9:56 am on Nov 24, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



As I understand things using "transitional" rather than "strict" gets you around issues over legacy pages using deprecated tags or even an old version of am editor creating them.

Actually for basic site without any styling you will probably find it working fine without a DOCTYPE at all. In my early days I never bothered and those pages are still working fine on all browsers.

kolin

10:53 am on Nov 29, 2007 (gmt 0)

10+ Year Member



UTF-8 basically allows all characters to be displayed on a webpage

ISO-8859-1 is a (Latin : A,B,C,D, etc) subset of characters from UTF-8.

if your site is just going to be in english then it's alright to just use iso-8859. if it's going to be multi-lingual, you should really use utf-8.

i'd stay away from 'windows-#*$!x', as i assume that it's microsoft only.

i personally always use utf-8 as you never know when a client comes back and asks for a multi-lingual!

hope this makes things a bit clearer....

[alanwood.net...]

might help...

rocknbil

7:46 am on Nov 30, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Can someone tell us what i need to stick in for it to be compliant!?

Many of these answers are probably confusing to a newcomer - maybe this will sort it out.

You can be compliant in 4.0 or XHTML, strict or transitional, this is a decision you make based on the requirements of the project at hand. To clarify, what you have there is a valid 4.01 document type definition. What this means in terms of your pages is that the pages will render in standards compliance mode, as opposed to quirks mode. In quirks mode, some of the features in CSS will fail to work as expected. In standards mode, if the css is not assigned correctly, it also will not work - the simplest example being color. #ff00ff is a valid color assignment in standards mode, ff00ff is not.

More info - Choosing the best document type for your site [webmasterworld.com]

If you are in Firefox, right now, right-click the background somewhere on this page and select View Page Info, then the General tab. It will tell you the render mode of this page.

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

The answer here is similar, "it depends." ISO is fine if you plan on always using standard ASCII characters, and do not foresee using "special characters" outside the standard ASCII character set, such as Microsoft "curly quotes". If your documents will contain foreign languages, you are definitely going to need another document type. This is also complicated by what type of encoding documents are served as by your web host

More information - Character Encoding, Entity References, and UTF-8 [webmasterworld.com]

I will add one thing: note you have an XML-style ending to your content-type:

/>

This is not valid 4.01 syntax. These are only required for XHTML documents. Pet peeve of mine. :-)

4.01

<br /> should be <br>
<img /> should be <img>
<hr /> should be <hr>