473,412 Members | 4,519 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,412 software developers and data experts.

White Space on Top?

Hello!

Im looking to try and get into CSS for formatting my sites. Seems like a
nice premise, and should allow easier design for the future. But gees,
Im having a hard time of it.

I would like to create something like at http://www.blargle.co.uk or
http://www.celebrityresearcher.co.uk without the tables.

I figure should be easy, to have two DIV rows, 100% width, and then have
three DIV columns underneath...

I couldn't even get past the two rows.

When I use absolute positioning, Firefox draws everything in the right
place, but doesn't give me 100% width. Unlike IE. However if I remove
the position property, Firefox does indeed draw the DIVS to the full
width of the screen.

Except, it also includes a white space at the top, like some kind of
margin! I've tried to set all margins to 0px and padding to 0px, but
still the white space on top remains - Unless I add a border, then it
all draws in the correct places.

Curiously, the differences between border 1px and border 0px seems to
just move the box while any text inside stays at the same position on
the screen.

Im confused...

I don't want to use border:1px and it seems most of everyone out there
uses borders, or separation between DIV elements, whereas I want to
retain my designs...

Sorry, I havent got any code on me, Im at work at the moment, and what I
have is at home, but I just wanted to run this past you. I am a newbie,
I have much to learn, I have searched, but can't find much in relation
to this particular issue. There's probably some glaringly obvious mistake.

Cheers
Simon

PS I'll try and post a URL tonight, but I think I have something like:

<div id=banner1>
<p>some text</p>
</div>
<div id=banner2>
<p>some text</p>
</div>

#banner1 {
background:#f00;
top:0px;
height:50px;
left:0px;
width=100%px;
}

#banner2 {
background:#0f0;
top:0px;
height:50px;
left:0px;
width=100%px;
}
Jul 21 '05 #1
3 8997
Simon Dean <sj****@simtext.plus.com> wrote:
I figure should be easy, to have two DIV rows, 100% width, and then have
three DIV columns underneath...

I couldn't even get past the two rows.

When I use absolute positioning, Firefox draws everything in the right
place, but doesn't give me 100% width. Unlike IE. However if I remove
the position property, Firefox does indeed draw the DIVS to the full
width of the screen.
You should always set a width for absolutely positioned elements. If
you don't then, as you've seen, browser behaviour varies. But I doubt
that you need absolute positioning at all.
Except, it also includes a white space at the top, like some kind of
margin! I've tried to set all margins to 0px and padding to 0px, but
still the white space on top remains - Unless I add a border, then it
all draws in the correct places.

Curiously, the differences between border 1px and border 0px seems to
just move the box while any text inside stays at the same position on
the screen. <div id=banner1>
<p>some text</p>
</div>
<div id=banner2>
<p>some text</p>
</div>


The paragraphs have a default top margin. Under CSS margin collapsing
rules this will collapse with the top margin of the parent div. So you
end up with a margin above the div that is the larger of the margin
set on the div (default zero) and the margin set on the paragraph
(default about one line height). See
http://www.w3.org/TR/CSS21/box.html#x25

To prevent margin collapsing the div needs a non-zero amount of either
padding or border. Or you can remove the margin-top from the first
paragraph via the :first-child selector (not supported by IE but as IE
doesn't collpase margins properly not an issue).

Steve

--
"My theories appal you, my heresies outrage you,
I never answer letters and you don't like my tie." - The Doctor

Steve Pugh <st***@pugh.net> <http://steve.pugh.net/>
Jul 21 '05 #2

You should always set a width for absolutely positioned elements. If
you don't then, as you've seen, browser behaviour varies. But I doubt
that you need absolute positioning at all.


Yes, must wrap my head around what they all mean, absolute should be
fairly straight forward, but static and relative are two unknowns to me
at the moment.

Curiously, the differences between border 1px and border 0px seems to
just move the box while any text inside stays at the same position on
the screen.


<div id=banner1>
<p>some text</p>
</div>
<div id=banner2>
<p>some text</p>
</div>

The paragraphs have a default top margin. Under CSS margin collapsing
rules this will collapse with the top margin of the parent div. So you
end up with a margin above the div that is the larger of the margin
set on the div (default zero) and the margin set on the paragraph
(default about one line height). See
http://www.w3.org/TR/CSS21/box.html#x25

To prevent margin collapsing the div needs a non-zero amount of either
padding or border. Or you can remove the margin-top from the first
paragraph via the :first-child selector (not supported by IE but as IE
doesn't collpase margins properly not an issue).


Ahh, OK, I think I just about understand that... Failed to realise that
it would seem from this newbies point of view, that each html tag can
have a property... I forgot about the <p> tag!

There sounds like a hell of a lot to learn, but it all seems so
flexible and customisable... should be interesting.

Thank you very much for your kind help!

Cheers
Simon
Jul 21 '05 #3
look at a few templates, to become familiar

http://wholives.com/tools/freestuff.htm

Jul 21 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Grumble | last post by:
Hello all, I want to read lines from a text file, where each line has the following syntax: token1:token2:token3 There could be white space between tokens and ':'
2
by: Malcolm Dew-Jones | last post by:
I am looking at xslt 1.0 and trying to understand if empty text nodes are supposed to be stripped or not as the default behaviour. 3.4 starts by listing rules for when white space is not stripped...
17
by: Stanimir Stamenkov | last post by:
Is it possible to make two inline elements to appear adjacent stripping any white space appearing in between in the source? Example: <span class="adj">1</span> <span class="adj">2</span>...
5
by: Applebrown | last post by:
Hello, basically, I'm just learning intermediate CSS and trying to convert my old table webpage completely to CSS. Hoorah, right? Well, it's not quite going as planned. It's an extremely simple...
0
by: Mark Moore | last post by:
I'm trying to layout a couple text input fields and their corresponding labels without using a table. When I was trying to debug my understanding of CSS, I was *very* surprised to see that span's...
5
by: Michael Shell | last post by:
Greetings, Consider the XHTML document attached at the end of this post. When viewed under Firefox 1.0.5 on Linux, highlighting and pasting (into a text editor) the <pre> tag listing will...
38
by: Xah Lee | last post by:
sometimes i wish to add white space in <p> as to achived effects similar to tab. what should i do? using empty image seems the sure way but rather complicated. (and dosen't change size with...
2
by: shagy | last post by:
Hi, I'm having a problem with a <select><option> which has white space in values... When I post the data I only get the first word (up to the white space). "Testing white space" becomes...
5
by: Richard Maher | last post by:
Hi, Can someone please show me how to tell Firefox to preseve white-space when returning the selectList.option.value attribute? I have change the style so that the white-space is preserved on...
4
by: mosesdinakaran | last post by:
Can any one explain how the rule is applied for the following Regular expression $Str = 'the red king'; $Pattern = '/((red|white) (king|queen))/'; preg_match($Pattern,$Str,$Val); Result:
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.