Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
Adding Doctype messes my page up :(
Old 09-09-2007, 12:14 PM Adding Doctype messes my page up :(
Nathand's Avatar
Extreme Talker

Posts: 233
Location: USA
Trades: 0
What's up with this? I have this code:

Code:
<html>
<head>
<title>Test</title>
</head>
<body bgcolor=#000000>

<table bgcolor=#000000 height="100%" width="100%" align="middle">
<tr>
<td>
<div align="center"><font color="white" size="30">hello</font></div>
</td>
</tr>
</table>

</body>
</html>
That's the most efficient way I found to center something, but if I add:

Code:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dtd">
Then the text is no longer centered?! It snaps to the top of the page? Why would adding a Doctype screw up my page?

-Nathan

Last edited by Nathand; 09-09-2007 at 12:15 PM..
Nathand is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 09-09-2007, 01:38 PM Re: Adding Doctype messes my page up :(
Defies a Status

Posts: 3,420
Trades: 0
Quote:
Originally Posted by Nathand View Post
Why would adding a Doctype screw up my page?
Before you told the browser what Doctype you were using, it assumed you didn't really know what you were doing, so it rendered the page in Quirks mode, where it attempted to interpret the code you wrote.

Once the Doctype was added, the browser decided you probably knew what you were doing and therefore rendered the page to web standards, in Standards mode.

Your best bet is to stop using tables to centralize your content and use divs and CSS to achieve this. This web site should help:

http://dorward.me.uk/www/centre/


Tables weren't designed to be used for styling, and as web standards continue to move on, it's best now to switch to CSS where possible to display styles.
CSS4Life is offline
Reply With Quote
View Public Profile
 
Old 09-09-2007, 02:59 PM Re: Adding Doctype messes my page up :(
Extreme Talker

Posts: 238
Location: United States
Trades: 0
Unfortunately, CSS2 doesn't have a property to vertically center stuff. You might think vertical-align might do it, but it only works for table cells and and inline elements. What you might think you could do instead, is to make the parent element act like a table cell (display: table-cell;) and vertically center it (vertical-align: center;). But it's not really that simple. If you want it to work in IE6 and IE7 without using tables, then you have to use CSS hacks. As far as I know, it's impossible to vertically align most elements without using invalid CSS or tables.

Using the HTML height attribute on a table is not allowed when following the doctype, and that's why your example doesn't work when you add the doctype. There is a workaround though, and the basis of it involves using the CSS height property on your table instead of the HTML attribute.

To center your page with valid CSS and tables: http://apptools.com/examples/tableheight.php

To center your page with CSS hacks and no tables:
http://www.jakpsatweb.cz/css/css-ver...-solution.html
__________________
The interlocking pieces of web development: usability, performance, accessibility, and standards.
frost is offline
Reply With Quote
View Public Profile
 
Old 09-09-2007, 04:16 PM Re: Adding Doctype messes my page up :(
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
Quote:
Originally Posted by whym View Post
Before you told the browser what Doctype you were using, it assumed you didn't really know what you were doing, so it rendered the page in Quirks mode, where it attempted to interpret the code you wrote.

Once the Doctype was added, the browser decided you probably knew what you were doing and therefore rendered the page to web standards, in Standards mode.

Your best bet is to stop using tables to centralize your content and use divs and CSS to achieve this. This web site should help:

http://dorward.me.uk/www/centre/


Tables weren't designed to be used for styling, and as web standards continue to move on, it's best now to switch to CSS where possible to display styles.
Is it just me or does LadyNRed and the like rub off on everyone on here
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 09-09-2007, 05:07 PM Re: Adding Doctype messes my page up :(
Defies a Status

Posts: 3,420
Trades: 0
Quote:
Originally Posted by dansgalaxy View Post
Is it just me or does LadyNRed and the like rub off on everyone on here
Lol. Well I support that tables should be used for their correct use (storing data) and not for presentational reasons.
CSS4Life is offline
Reply With Quote
View Public Profile
 
Old 09-09-2007, 05:41 PM Re: Adding Doctype messes my page up :(
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
You seriously dont know how much you should like LNR XD Lol
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Old 09-09-2007, 08:16 PM Re: Adding Doctype messes my page up :(
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
He can sound like me all he wants to
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 09-10-2007, 05:35 AM Re: Adding Doctype messes my page up :(
dansgalaxy's Avatar
Defies a Status

Posts: 6,521
Name: Dan
Location: Swindon
Trades: 0
Haha! LOL i know, sorry LNR its jsut everybody talks about it reminds me of you kinda weird?

Dan D
__________________
Discounted Web Hosting With XDnet!
>> Get 25% of hosting~ Promo: Webmaster-talk <<

Please login or register to view this content. Registration is FREE
dansgalaxy is offline
Reply With Quote
View Public Profile Visit dansgalaxy's homepage!
 
Reply     « Reply to Adding Doctype messes my page up :(
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.75360 seconds with 12 queries