View Full Version : body { margin: 0px; padding: 0px; }

06-08-2003, 11:07 PM
body { margin: 0px 0px 0px 0px; padding: 0px; }

Is this usefull at all or is it default ?

06-08-2003, 11:35 PM
Yeah it is useful, as it replaces a load of browser specific HTML tags and attributes that people usually use.

Run any site you like through http://validator.w3.org/detailed.html and you will find many that have a whole load of error messages like:

marginwidth is not a valid attribute and so on.

That CSS removes those errors. Use it!.

The four margin errors can be replaced with a little bit of CSS code instead. Put this is a text file, with a name ending in .css:

body {
margin: 0px;
padding: 0px;

In CSS you must have units with all of your numbers, so one of either px, pt, em, %, or # is always required.

You should export the CSS to an external file and call it with a one line instruction in the <head> section:
<link type="text/css" rel="stylesheet" src="/path/file.css">

External CSS files must not contain any HTML tags or code.

06-09-2003, 12:08 AM
Originally posted by giz
Put this is a text file, with a name ending in .css:

As long as the <link> has type="text/css" in it, the extension is irrelavent as the MIME type is what is needed, I always use .css too for good practice tho.

Yes it's useful if you want it. ;)

margin:0px 0px 0px 0px; will take care of each side of the element, starting from the top going clockwise, if all values are zero, you may as well just use margin:0px;.

06-09-2003, 04:01 AM
So it IS necessary that I use these styles?

06-09-2003, 05:35 AM
No, of course not.
In an HTML document, CSS is never necessary.
You would use it only if you wanted to remove the margin/padding.

06-09-2003, 09:19 PM
You should use the CSS codes in place of the browser specific HTML codes for marginwidth and marginhelight and so on, assuming that you have that HTML on your site.

Run your site through the code validator. If you see a whole load of errors relating to margins then that new piece of code is just for you.

06-09-2003, 09:42 PM
if the value is 0 you don't need a unit:


is fine. Personally, I always use this - even if I do want body margins, it's much easier to specify them as margins or padding of internal elements, I find. And this way you can have your navigation strip run the full width of the page while main content is padded.

06-09-2003, 11:35 PM
Originally posted by giz
Run your site through the code validator.


06-10-2003, 01:40 AM
>> How? <<


06-10-2003, 05:28 AM
Each time I try that it doesn't work

I was not able to extract a character encoding labeling from any of the valid sources for such information. Without encoding information it is impossible to validate the document. The sources I tried are:

The HTTP Content-Type field.
The XML Declaration.
The HTML "META" element.
And I even tried to autodetect it using the algorithm defined in Appendix F of the XML 1.0 Recommendation.

Since none of these sources yielded any usable information, I will not be able to validate this document. Sorry. Please make sure you specify the character encoding in use.

IANA maintains the list of official names for character sets.

That's what it ALWAYS says, I don't understand :( It's just a little simple site:

Vous Etes Perdu ?
<H1>Perdu sur l'Internet ?</H1>
<H2>Pas de panique, on va vous aider</H2>
<STRONG><PRE> * <----- vous &ecirc;tes ici</PRE></STRONG>

(That's not my site btw)

06-10-2003, 11:55 AM
I think you are looking for this:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

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

06-10-2003, 11:20 PM
For your page to actually be valid you MUST declare the character encoding used for the page, with something like:

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

There are also other schemes such as UTF-8 and many others,

It is also a good idea to declare what language the page is in, using:

<meta http-equiv="Content-Language" content="EN-GB">

The language and country codes come from ISO 4217 and ISO 3166.

You do need the meta description tag, and it is useful but not vital to have a meta keywords tag:

<meta name="Description" content=" Your Description Here. ">
<meta name="Keywords" content=" your, keyword, list, here ">

Your document should begin with a !DOCTYPE and a title element:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<title> Your Title Here </title>

The last parts of your header should have your links to external style sheets and external javascript files:

<link type="text/css" rel="stylesheet" src="/path/file.css">

<script type="text/javascript" language="javascript" src="/path/file.js"></script>



06-11-2003, 01:30 AM
Does all that do anything else than make the validator work?

06-11-2003, 01:43 AM
Good question!!! :thumbsup:

I know that when I put the doc type at the top of some of my pages that have scripts in them the scripts seem to no longer function in IE 5.1.6 for MAC and they get a little weird in Netscape 4.76 for Mac as well.

Can't wait to hear the answer to this one.


06-11-2003, 02:26 AM
These bits are required by the validator, but they are also required by the user's browser as well:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

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

The <title> is also required by the browser, and is most important to the search engines.

The meta description (and sometimes the meta keywords too) as well as the meta Content-Type are required by search engines. The language tag becomes important in online translation tools and in some search engines.

Use all of that code then you know that you have covered every angle: validator, browsers, users, search engines.

06-11-2003, 02:36 AM
How are they used by the browsers? What does a browser do if there is no doc type specified? I have not had a doctype on any of my pages until recently and had absolutely no problems getting in the top ten on search engines without it. As far as browsers are concerned I have more trouble getting things to work in certain ones(older versions) with a doctype than without one.


06-11-2003, 05:31 AM
Modern browsers go into Quirks Mode w/o Doctype. To simplify IE6 emulates IE5 in some aspects, Moz old Netscape and Opera probably partly mimics IE, I think.

The charset should be sent in the server's HTTP headers. Meta is just a poor substitute or an add-on, which way you choose to see it. Without charset the browser don't know what character set that should be used. Not all pages are written in iso-latin and not all browsers are set to use that as default.

06-12-2003, 09:32 PM
I think it's wrong to think in terms of how will the doctype affect my page. The doctype is a description - if your page is transitional HTML 4 then that's the doctype to use; if it's XHTML 1.0 Strict then use that one. What you should not (imo) do is use a DOCTYPE which does not accurately describe the document simply to enforce a particular rendering behavior.

These things are descriptive - DOCTYPE tells the interpretor what type of document it is; content-type declares the mime-type and character encoding; lang declares the language.

Most of us have been, or are, lazy about or unaware of these things, because we've "grown up" with tools that assume values where the values are not defined; arguably that's wrong - if a document does not declare what it is, the brower should not even attempt to render it.

It can seem unimportant from one perspective - the perspective of a PC-using surfer with a visual browser, and no disabilities or special requirements. But for people with special accessibility needs; for people who use non-standard interfaces; for robots and other machine-readers, these things are critical - how does a screenreader know what voice to use if it doesn't know what language the document is in? How can a semantically aware robot gather meaningful information from a document if the document doesn't say what format it's in and how it's encoded?

How does a browser even know how to render the code when the code doesn't say if it's HTML, XHTML or XML? Sounds silly - but the vast majority of webpages are like this. So how does any of it work at all?

How? By guesswork - 'oh well, it doesn't say, so we'll assume transitional HTML 4 in ISO-whatever and US-english'. That propensity to guesswork is the root of our x-browser woes; it's the basic cause of internet accessibility problems; it's the reason why, despite the awesomeness of the internet, reliable primary data on a given subject can still be very hard to find.

So use the right markup, and use it right - it's the way out :)

06-14-2003, 06:39 AM
Originally posted by brothercake
use the right markup, and use it right - it's the way out :)
Spoken like a true hardcore guru, and I got your back. :cool:

06-14-2003, 06:46 PM
Ok ok, I get it now :)

So do I have to put that Doctype stuff on all of my pages ...Or just on the main page... Or have it on a seperate file and linked to all my pages... Or whatever?

06-14-2003, 10:39 PM
All of that stuff for the <head> section, that I mentioned 9 or 10 posts back in this thread, needs to go on every page of the site.

To get a better ranking in search engines each page should also have a customised and optimised title and description relevant to the contents of that page.

06-18-2003, 03:01 AM
Originally posted by giz
To get a better ranking in search engines each page should also have a customised and optimised title and description relevant to the contents of that page.

Interesting and informative thread. Glad to see I've been doing it right!! *S* BUT .... here's an interesting angle .... what if you don't want the search engines to spider through your pages? What if you have a few pages on your site that you don't want the search engines to find? Is there a way to stop them from spidering those specific pages?

06-18-2003, 06:02 AM
Put this on the pages that you do not want to be indexed:

<meta name="robots" content="noindex,follow">

06-18-2003, 10:03 AM
Got it !! Thanks Giz. :thumbsup:

06-18-2003, 11:02 AM
hmm well .. arguably ... using title, description or any other meta-information purely for the purpose of improving search-engine rankings, is a misuse of meta-information.

06-18-2003, 04:19 PM
Why would that be brothercake? I changed the title and keywords tags in my pages, although they acurratly describe my home page and my business and now I am in the top 10 on every search engine I have tried. Even without submitting my site to most of them. It does seem to have an effect.


06-18-2003, 04:39 PM
Yeah it has an effect - if your keywords are giving you good rankings, then that's great. All I'm saying is that, in my opinion, using keywords specifically for the purpose of improving SE rankings, is wrong, because it's not what keywords are for. Keywords are for attaching words to your document which are relevant - and that's one of the things SEs may use for indexing and ranking - but that's by the by in a sense, because they are not for having good SE ratings; search engines are merely a consequent example of something which uses that meta information.

To put it another way - if your site is the best source of information for its subject, it should naturally rise to the top. If you try to force that to happen artificially, then that's an abuse of the search engine paradigm.

All IMO ..

06-18-2003, 07:19 PM
Ok. I understand. I am sure there is a point where one could be "misleading" by putting in keywords or phrases in a title that really do not apply solely for "rankings".


06-18-2003, 09:43 PM
I totally agree that filling the title and meta description tags with a list of keywords has no benefit to the end user, and I hope that my post did not imply that doung that is of any benefit to anyone.

On the contrary, these tags should have plain language in them, the sort of thing that would be useful to a human to read, whilst still containing words that you want the search engines to index that page for.

What I was implying, is that you should not use the same information on every page.

This is useless:
The Widget Site
The Widget Site
The Widget Site
The Widget Site
The Widget Site

You should do something like:
The Widget Site - A guide to all widgets
History of the Blue Widget
Green Widgets developed in 1956
The elusive Red Widget
Buy your Widget here