Forum Moderators: open

Message Too Old, No Replies

How do get rid of the gap at the top of the page ?

there is a gap above my table :(

         

diddlydazz

11:03 am on Dec 14, 2001 (gmt 0)

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



I have a gap above my table which is a different colour to the page, any way to get rid of it without changing the page colour ?

also is there a way to make the table cover the whole width of the page because it has a gap at the sides aswell.

Any advice appreciated.

Thanks in advance

DaveN

11:07 am on Dec 14, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



diddlydazz,

Would need to see code snip really
(just the a couple of lines above and below the table tag) or sticky me the URL.

DaveN

diddlydazz

11:19 am on Dec 14, 2001 (gmt 0)

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



<html>

<head>
<title>test</title>
</head>
<body bgcolor="#006699" link="#FFFFFF" vlink="#FFFFFF">

<table border="0" width="100%" cellspacing="0" cellpadding="0" bgcolor="#81ABAB">
<tr>
<td width="33%" valign="middle" align="center" bgcolor="#81ABAB"><img border="0" src="newlogo.jpg" width="312" height="58"></td>
<td width="27%" valign="bottom" align="center">

Thanks

is that enough ?

gethan

11:21 am on Dec 14, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The following works in most browsers... (not old netscape).

<body bgcolor='#bgcolor' topmargin=0 leftmargin=0 rightmargin=0>

Have a play and see what looks best on your site.

Good luck

diddlydazz

11:23 am on Dec 14, 2001 (gmt 0)

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



cheers I will try it :)

DaveN

11:24 am on Dec 14, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



gethan's right the default for most browser's (i think ) is 5 pixel margin all around

<body bgcolor="#006699" link="#FFFFFF" vlink="#FFFFFF" topmargin=0 leftmargin=0 rightmargin=0 >

should cure your problem
DaveN

caine

11:26 am on Dec 14, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



dizzydazz,

<body bgcolor="#333333" text="#000000" marginwidth="0" marginheight="0" leftmargin="0" topmargin="0">

The line of code above is similar to Gethan's, but he missed the marginheight="0"

topmargin + leftmargin is one browser

marginheight + marginwidth is another

this works for IE, NN, and opera which follow's the NN variation.

gethan

11:27 am on Dec 14, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Cheers Caine -- nice to have the gap in my knowledge disappear as well as the one on my pages in Netscape :)

diddlydazz

11:37 am on Dec 14, 2001 (gmt 0)

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



EXCELLENT !

cheers both for your help !

merry xmas :)

Brett_Tabke

3:19 pm on Dec 15, 2001 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



<body bgcolor="#333333" text="#000000" marginwidth="0" marginheight="0" leftmargin="0" topmargin="0">

Thats nonstandard code and only works in IE. Use CSS for a universal solution. Be sure to set padding to 0px.

body {margin 0px; padding: 0px}
or
table {margin 0px; padding: 0px}

Will

5:42 pm on Dec 15, 2001 (gmt 0)



Brett has the best solution - another way is

<body marginheight="0" marginwidth="0">

which works not only in IE but also older versions of Netscape (which are generally the most problematic with regard to borders anyway).

However, this is also nonstandard code so try to use the CSS if possible.

keyplyr

8:01 pm on Dec 15, 2001 (gmt 0)

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



>Thats nonstandard code and only works in IE. Use CSS for a universal solution. Be sure to set padding to 0px.

I was using the margin=0 but was looking for a better cross-browser solution. However, I can't seem to get the css to work:

<style type="text/css">
body {margin 0px; padding: 0px}
</style>

Is this not how to write it?

I also tried inline:

<body bgcolor="#333333" text="#000000" {margin 0px; padding: 0px}>

Still not working

seriesint

10:20 pm on Dec 15, 2001 (gmt 0)



The style declaration looks right, it is in the HEAD tag of the page?
As for the inline example you have to have it as

<body style="margin:0;padding:0;">

Drop the { } when its inline.
Try to use the code in the HEAD section, its easier to track there.
Can skip the px,pt,em, whatever. 0 is 0 ;)

HTH

keyplyr

10:37 pm on Dec 15, 2001 (gmt 0)

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



Update: working now, thank you.

How well is this supported? I currently have the margin=0 (on the actual website) and realize that only IE5+ support it, but would switching to CSS also leave many behind?

(edited by: keyplyr at 10:53 pm (gmt) on Dec. 15, 2001)

seriesint

10:52 pm on Dec 15, 2001 (gmt 0)



umm

<body bgcolor="#F0FFFF" text="#000000"
link="#660000" vlink="#660000" style="margin:0;padding:0;">

Works in IE6 , though for some reason I just don't see, it doesn't work from the head tag. I changed it so there was just one declaration but still no dice. Above works though. I'll play with it a few more to see what's holding it up. Alright, this does it in IE6, have to apply it to the HTML element(in the head section) as in
<style type="text/css">
html { margin:0; padding: 0; }
body { /*your other rules here */ }
</style>
Though I believe in IE5 , it will NOT accept a ruleset for the HTML element unless you have a doctype declared. Hopefully, that didn't just totally lose you :)

HTH

keyplyr

10:58 pm on Dec 15, 2001 (gmt 0)

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



Thanks. I was possibly uploading the "fixed" TEST page when you looked at it.

To maintain backwards support, could I use the margin=0 in the body tag as well as CSS in the HEAD for the other browsers?

seriesint

11:00 pm on Dec 15, 2001 (gmt 0)



Well the general caveat is that NS 4 is just a lost cause for CSS support. Which is why some suggested those additions to the BODY tag for marginheight or whatever, I just let the NN users suffer through the gap and make sure the code is valid. IE4 should accept that as well since its basic CSS level 1. But it has been a long time since I used IE4. Can look here and see just about all the 4 series browsers are buggy or partial support, so its 5+ type of deal.

[westciv.com.au...]

seriesint

11:14 pm on Dec 15, 2001 (gmt 0)



Those speciality tags for NN and IE, will cause the page to not validate at w3c.org. They will do what you want though. If that isn't a concern, then go ahead and use them.

*waiting for the "it must validate!!" crowd to come forward and lynch me*

keyplyr

12:02 am on Dec 16, 2001 (gmt 0)

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



Thanks again seriesint,

Yes I understand about the rogue code not validating. My HTML is solid but I use several codes that kick up flags at validators.

I use width and height inside forms also, but without them the graphics load noticably slower. Also, some C&P affiliate codes use tags that cause "errors" at the W3C val but without them, the application does not work.

My object is to have great looking/functioning pages, not to have good "grades" (he says while keeping head low in anticipation of oncoming stones)

Marshall

4:04 pm on Dec 16, 2001 (gmt 0)

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



Just a reminder - if you don't include a format after margin-whatever: 0;, such as pixels or percentages - margin-whatever: 0px;, some browsers will ignore it.

tedster

4:13 pm on Dec 16, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



>> *waiting for the "it must validate!!" crowd to come forward and lynch me*

This non-standard code can validate -- if you create a custom DTD. In fact, you'll see on the "Reference" link below that this is one common reason for customizing your DTD.

Reference [htmlhelp.com]

seriesint

4:55 pm on Dec 16, 2001 (gmt 0)



>>some browsers will ignore it.

Which specific browser are you referring to?

tedster
>>This non-standard code can validate -- if you create a custom DTD.

Man, I don't know about the validating crowds you hang around with, hacking up the DTD would get cries of "it still isn't w3c standards code" for HTML 4.0 or 4.1. XHTML ,that might be a valid option though I still am not convinced of its validity on changing attributes for already defined elements. Declare a new namespace and provide alternate styles for those, sure, but altering the base elements you might as well just live without the little w3c logo on the page.

Marshall

5:04 am on Dec 17, 2001 (gmt 0)

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



seriesent,

Specifically, I don't know which browsers will ignore margin spacing if you don't include pixels or percentages. It's one of those things I read once. Maybe it's no longer true, but why take a chance.

Brett_Tabke

9:19 am on Dec 18, 2001 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



It makes good sense to use the px/pt/em designator. Just as with hex values. There are browsers that will not read a hex value (in css) unless it has the # in front of it.

>waiting for the "it must validate!"

Contrary. Most of us don't drum the validation mantra too loud (see: goose/gander fable). Mostly, if there is a validating solution to code, we try to encourage it. If it were just you and me, we might do what ever it took to get the page to look the way we want - but we are in an audience here.

If there has ever been more copied code than html, I don't what it would be (maybe the basic "Hello World" program would be it). So, we try to stay away from the browser specific extentions like margin in the body tag. Try something along the lines:

<body style="margin: 0px; padding 0px">

Marshall

1:16 pm on Dec 18, 2001 (gmt 0)

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



"<body style="margin: 0px; padding 0px">" doesn't work in NN4. You either have to use marginheight and marginwidth in the body tag or absolute positioning. From viewing the thread on what's the percentage of NN users, there are still a considerable number and that has to be taken into consideration. Besides, what good are rules if you don't bend them.

keyplyr

5:16 am on Dec 19, 2001 (gmt 0)

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



>This non-standard code can validate -- if you create a custom DTD.

Brett (or anyone), I did use that reference page to create a custom DTD defining the non-standard margin codes in the body statement and using the suggested DOCTYPE at the top of my mark-up.

Questions: Should this DOCTYPE be in every page of the website if the same conditions exist within the mark-up?

Also, this custom DTD document weighs in at a hefty 45k of pure text. Other than a validator, will browsers be downloading this document?

Xoc

6:10 am on Dec 19, 2001 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



No, a browser doesn't look at the actual DTD. Only a validator will. Some browsers will, however, look at the DTD string in the HTML and render things differently based off that string.

Brett_Tabke

2:20 am on Dec 23, 2001 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



In response to this very question of padding and margins, Sue Simm (of Opera Software) recommended the following:


> Perhaps you can explain why Opera
> feels it necessary to give 'body'
> a padding value of 8px,

Sure, I can explain it. Pick one of these explanations:

1) It was a dreary Thursday in Norway, and the mood of the developer in charge of Opera's default stylesheet matched the weather. On leaving Opera that day, he noticed that someone had parked 8px from his own parking spot, thereby making it impossible for him to leave. Irritated beyond belief at the insensitivity of that individual, he decided to set Opera's default padding to 8px.

2) It was a bright and sunny day in Norway, when the developer of Opera's default stylesheet made the decision to use the default stylesheet suggested by the W3C as Opera's default. [w3.org...]

Sue