473,395 Members | 2,192 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Which DOCTYPE should I use?

i There,

I finally launched my site and it looks good on safari and firefox, however in Explorer some of the pages are wonky. It looks as if some of the classes are not properly applied. I find it weird considering there are other pages on the site with the same classes applied to them and are showing correctly. I tried searching for solutions online and I was reading articles about DOC TYPES but I can't get my head arund it.

What kind of DOC TYPE should I use? Would anyone happen to know the code for it?
Jan 20 '11 #1

✓ answered by Dormilich

basically you can use 2 doctypes: HTML 4.01 or HTML5. HTML5 is recommended if you plan to use some of its new functionality/elements.

HTML 4:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2.             "http://www.w3.org/TR/html4/strict.dtd">
HTML5:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html>
if you absolutely need frames, you’ll need the Transitional or Frameset variant of HTML 4.

PS. don’t forget to validate your code: http://validator.w3.org/

9 2526
Dormilich
8,658 Expert Mod 8TB
basically you can use 2 doctypes: HTML 4.01 or HTML5. HTML5 is recommended if you plan to use some of its new functionality/elements.

HTML 4:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2.             "http://www.w3.org/TR/html4/strict.dtd">
HTML5:
Expand|Select|Wrap|Line Numbers
  1. <!DOCTYPE html>
if you absolutely need frames, you’ll need the Transitional or Frameset variant of HTML 4.

PS. don’t forget to validate your code: http://validator.w3.org/
Jan 20 '11 #2
drhowarddrfine
7,435 Expert 4TB
Doctype is short for "Document Type Definition" and DTD. Essentially, it's the rules set for each element on the page. If you don't define which set of rules you are using ahead of time, then you are in 'quirks mode' and it's like 1998 all over again.

New web pages should always use the strict doctype as shown by Dorm above. However, there is no problem using the so called "html5 doctype" since this puts all browsers in 'standards mode' which is the same thing as HTML 4.01 strict.

The doctype is the very first thing you start with on a page and never, ever change it.
Jan 20 '11 #3
GREAT! Thank you :)

what do you mean by frames? I am mainly using tables and ap divs? Can you give ma an example?
Jan 20 '11 #4
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

That is the doc type that was automatically in my code. So just confirm I need to change this to the code provided by dormilich? Just confused because "drhowarddrfine" says never to change it? :s
Jan 20 '11 #5
Dormilich
8,658 Expert Mod 8TB
if you don’t know about frames, leave it as such (frames are outdated anyways)
Jan 21 '11 #6
drhowarddrfine
7,435 Expert 4TB
@Melissa,
The transitional doctype is for web pages containing older, deprecated markup that you are transitioning or combining with newer pages. Particularly, this helps with validation as the older markup won't get flagged as errors. So new web pages shouldn't be using deprecated markup and, therefore, no one has any need for the transitional doctype.

But once you've started working on a page, you should never change the doctype you are using. Change the doctype and you are changing the rules you are telling the browser you are using and this may alter the rendering of the page. So don't do that.
Jan 21 '11 #7
@drhowarddrfine
So what do I have to do in order to make my website look the same in all browswers? If my current DOCTYPE is was I indicated in a previous post?
Thanks :)
Jan 21 '11 #8
drhowarddrfine
7,435 Expert 4TB
You can use that doctype without issue. Getting pages to work in all browsers is not much of a problem. Only IE is a problem. The worst browser on the planet, inept at best, and 13 years behind all others in modern standards and practices. It's an embarrassment to Microsoft.

So the only real "trick" is, test your page first in anything but IE. If you add something and test in Firefox, glance at Chrome/Safari/Opera to see how it looks there. If it looks fine, and you validated your HTML and CSS, then you know your markup is correct.

Then look at IE. Chances are something will be screwed up. Just make sure you aren't trying to "fix" your markup for IE's sake. That's how so many people run into trouble. There are hundreds of web sites dedicated to fixing IE's problems as the problems and fixes are well known. (There are none, and none needed, for any other browser.)
Jan 21 '11 #9
Dormilich
8,658 Expert Mod 8TB
www.positioniseverything.net for example
Jan 22 '11 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: bbxrider | last post by:
this is my first page so i'm terribly lost on which doctype to use, i'm hoping there's a basic type that doesn't require hours of research i had been using, <!DOCTYPE html PUBLIC "-//W3C//DTD...
8
by: CMAR | last post by:
I create my website using Front Page 2000. I notice that none of my pages have a DocType statement at the top. I have read that if you want IE6 to use "Standards mode" rather than the "Quirks...
2
by: DartmanX | last post by:
I doubt this is possible, but I want to ask, just in case it is. I have a project going using Google Maps. This project spits out an HTML page template for people to post to their website and...
6
by: jperillo | last post by:
When I validate the source of http://www.24stores.com I'm told that I have an incorrect DOCTYPE statement. How can I, or can someone determine what I'm doing wrong !! I have no idea which...
24
by: Jim Michaels | last post by:
I can't get any "universal" code working that tries to detect whether the document it's in is xhtml or html. I found this, which tells me I have a hill to climb with no equipment....
6
by: Rolf Welskes | last post by:
Hello, if I have for example: <table style="width: 100%; height: 100%;" border="1"> <tr> <td style="width: 100px">k </td> <td style="width: 100px">k </td> </tr>
2
by: mszanto | last post by:
I've read a bunch of posts on this and none of the answers are legitimate (IMHO) so I thought I'd throw it out there again. Using the html code below, if you set the doctype to HTML 4.0, and...
5
chunk1978
by: chunk1978 | last post by:
hi there... i've got a page that includes CSS, JavaScript and HTML codes... i'd like to know which Doctype i should use at the start... currently there is no Doctype included at all, and it seems...
0
drhowarddrfine
by: drhowarddrfine | last post by:
The Doctype or DTD Many coders get confused by all the talk of doctypes and how they affect browsers and the display of their web pages. This article will get right to the point about doctypes...
6
by: WT | last post by:
Hello, I am searching for a way to generate automatically from codebehind the <!Doctype....for asp.net pages using .net 3.5 c# and vs2008. Subidiary question: if I do a server transfert in my...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.