Jump to content

CSS margin problem


Recommended Posts

Hi guys! I want to make my own website but I always find the same problem... I am working in Dreamweaver and I want one div which will center all content. In Dreamweaver everything is alright but when I open my website in Mozilla, Chrome or IE it is NOT centered! Anybody can help me? ThanksHere is code of index.html which is placed in folder named site:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="shortcut icon" href="img/symbol.ico" /><link rel="stylesheet" type="text/css" href="css/style1.css" /><title>... Site's caption ...</title></head><body> <div id="sitebody"> sxs </div></body></html>
And here is my style1.css placed in site/css/:
@charset "utf-8";/* CSS Document */body { padding:0px; margin:0px; border:none; }; #sitebody { position:relative; padding:0px; margin:0px auto; width:900px; };
Any ideas where might be problem? Thanks :)
Link to post
Share on other sites

Quick, change that transitional doctype to a strict one and watch the pieces fall into place!

Link to post
Share on other sites

It works just fine for me. The div is 900px wide and centered on screen (Using FF) though the text inside the div is not centered, the div itself is.Yes, do take chibineku's advice and switch to a Strict DTD right now, before you get in the habit of using old coding styles.EDIT: Yea and ditch the positioning, like scientist said. There are applications for it but it's a bad habit to get into using it for basic styling and positioning. Margins, padding, display, and float should be used instead.

Edited by ShadowMage
Link to post
Share on other sites

Oh thanks, problem solved! First, I changed that transitional type to a new one (thanks for advice), however it didn't work. Then I deleted that semicolons in CSS code and it's working. :) ThanksPS: Adding position:relative in #sitebody was one of many unsuccessful tries I just forgot to delete it from code...

Edited by lambik
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...