472,958 Members | 2,042 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

Padding is not zero

page: http://reenie.org/test/blockpadding.htm
code:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>test</title>
</head>
<body>
<h2 style='padding:0; border:solid 1px red;'>A bunch of text</h2>
</body>
</html>

Why is there padding in the heading, above and below the text, and how
do I get rid of it ?
Nov 7 '08 #1
8 2848
RW
rodeored schreef:
page: http://reenie.org/test/blockpadding.htm
code:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>test</title>
</head>
<body>
<h2 style='padding:0; border:solid 1px red;'>A bunch of text</h2>
</body>
</html>

Why is there padding in the heading, above and below the text, and how
do I get rid of it ?

That's the body's margin or padding,

try <body style='margin:0; padding:0;'>
--
Rob
Nov 7 '08 #2
rodeored schrieb:
page: http://reenie.org/test/blockpadding.htm
code:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
<title>test</title>
</head>
<body>
<h2 style='padding:0; border:solid 1px red;'>A bunch of text</h2>
</body>
</html>

Why is there padding in the heading, above and below the text, and how
do I get rid of it ?
If it were padding it were _inside_ the border. So it's h2's default
probably margin.

--
Johannes Koch
In te domine speravi; non confundar in aeternum.
(Te Deum, 4th cent.)
Nov 7 '08 #3
On Nov 7, 12:09*am, RW <robwaaijenb...@hotmail.comwrote:
rodeored schreef:
page:http://reenie.org/test/blockpadding.htm
code:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
* *<title>test</title>
</head>
<body>
* *<h2 style='padding:0; border:solid 1px red;'>A bunch of text</h2>
</body>
</html>
Why is there padding in the heading, above and below the text, and how
do I get rid of it ?

That's the body's margin or padding,

try <body style='margin:0; padding:0;'>

--
Rob
No its not the baody margin. its padding inside the heading.
Nov 7 '08 #4
On Nov 7, 3:04*am, Johannes Koch <k...@w3development.dewrote:
rodeored schrieb:
page:http://reenie.org/test/blockpadding.htm
code:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
* *<title>test</title>
</head>
<body>
* *<h2 style='padding:0; border:solid 1px red;'>A bunch of text</h2>
</body>
</html>
Why is there padding in the heading, above and below the text, and how
do I get rid of it ?

If it were padding it were _inside_ the border. So it's h2's default
probably margin.

--
Johannes Koch
In te domine speravi; non confundar in aeternum.
* * * * * * * * * * * * * * *(Te Deum, 4th cent.)
it is is padding inside the heading. . it is not a margin. it is
padding.
Nov 7 '08 #5

rodeored wrote:
On Nov 7, 3:04 am, Johannes Koch <k...@w3development.dewrote:
>rodeored schrieb:
page:http://reenie.org/test/blockpadding.htm
<body>
<h2 style='padding:0; border:solid 1px red;'>A bunch of text</h2>
</body>
Why is there padding in the heading, above and below the text, and how
do I get rid of it ?

If it were padding it were _inside_ the border. So it's h2's default
probably margin.

it is is padding inside the heading. . it is not a margin. it is
padding.
No, it is not padding. Inside the borders, that extra space above and
below the text is part of the default line-height - space reserved for
character ascenders (e.g. ) and descenders (y). You may or may not be
able to get rid of it by changing the line-height to something less than
1, but beware that if line wrapping occurs, text may overlap. It will
certainly be harder to read.

--
Berg
Nov 7 '08 #6
In article
<de**********************************@40g2000prx.g ooglegroups.com>,
rodeored <in***@reenie.orgwrote:
On Nov 7, 12:09*am, RW <robwaaijenb...@hotmail.comwrote:
rodeored schreef:
page:http://reenie.org/test/blockpadding.htm
code:<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html>
<head>
* *<title>test</title>
</head>
<body>
* *<h2 style='padding:0; border:solid 1px red;'>A bunch of text</h2>
</body>
</html>
Why is there padding in the heading, above and below the text, and how
do I get rid of it ?
That's the body's margin or padding,

try <body style='margin:0; padding:0;'>

--
Rob

No its not the baody margin. its padding inside the heading.
As someone else posted, if you are referring to the space between your
red border on h2 and the text inside h2, that is the effect of line
height. If you are referring to space between the red border and the
body (i.e. in this case the top of the view port in the browser window)
it is probably a combination of default margin on the h2 and default
padding on the body.

It is easy to test: did you actually try the suggested changes to
body and h2 (i.e. styling BOTH to have margin: 0; padding: 0;)?

Remember that the margin goes OUTSIDE the border, the padding goes
INSIDE (except, IIRC, in IE's broken quirks-mode box model?)

By the way, semantically speaking, the first header in your body
should be an h1 (first level heading). If this is too big for your
liking, you can always override the browser's default size by
styling it accordingly.

<h1>This is the main heading for the content</h1>
<h2>This is the first section sub-heading</h2>
<h3>This is a subsection sub-heading!</h3>
<p>Etc.</p>
Nov 7 '08 #7
On Nov 7, 6:50*am, Bergamot <berga...@visi.comwrote:
rodeored wrote:
On Nov 7, 3:04 am, Johannes Koch <k...@w3development.dewrote:
rodeored schrieb:
page:http://reenie.org/test/blockpadding.htm
<body>
* *<h2 style='padding:0; border:solid 1px red;'>A bunch of text</h2>
</body>
Why is there padding in the heading, above and below the text, and how
do I get rid of it ?
If it were padding it were _inside_ the border. So it's h2's default
probably margin.
it is is padding inside the heading. . it is not a margin. it is
padding.

No, it is not padding. Inside the borders, that extra space above and
below the text is part of the default line-height - space reserved for
character ascenders (e.g. ) and descenders (y). You may or may not be
able to get rid of it by changing the line-height to something less than
1, but beware that if line wrapping occurs, text may overlap. It will
certainly be harder to read.

--
Berg
Thanks, that makes sense.
Nov 7 '08 #8
Bergamot wrote:
Inside the borders, that extra space above and
below the text is part of the default line-height - space reserved for
character ascenders (e.g. ) and descenders (y).
That's probably a helpful informal description, but it's not technically
quite correct.

Consider an element like <div>N</divwith border: solid 1px and with
padding not set (or, for definiteness, padding explicitly set to 0). A naive
assumption might be that the border touches "N" both at the top and at the
bottom. But as you note, it turns out that this would be pragmatically all
wrong.

But even if you consider <div>y</div>, you probably see (depending on font
etc.) that there is still some space above the tilde and below the descender
of "y".

Next, if you set line-height: 1 (making line height equal to the size of the
font, i.e. the nominal height of the font), you will see variation: there
might still be spacing, or the tilde or the descender might cross the
border. This is simply a matter of font design.

There is fairly popular belief saying that font size is the overall height
of the font, including ascenders and descenders and diacritic marks. It is
second-best approximation to truth in this matter and surely much better
than most of what we see written about font size. But it really cannot be
the whole truth. A simple proof is that by character code standards,
diacritic marks can be stacked with no pre-set limitation, and apparently
you go out of bounds at _some_ point.

The truth is that font size is a property assigned to the font by the font
designer, normally expected to provide sufficient height for all characters
including the fancy stuff, but the designer may design otherwise. One can
also say that a font designer works inside a square, the em square, and
designs glyphs inside it but not necessary utilizing the full height (and
hardly ever the full width, for Latin letters at least) and, on the other
hand, feeling free to cross the limits occasionally when he decides so. A
typical example is the letter , A with a ring above, occurring in
Scandinavian languages. Due to the nature of the ring, the letter very often
extends beyond the "upper limit" of the font - and there might even be
another diacritic, like the acute, above the circle, in some languages.

When you have set line-height: 1 (which I mention for a frame of reference
only - it is almost always too small, but sometimes suitable when you really
know and understand your text and context and their stability) and padding:
0, then there is no space between a border and the font height, though of
course individual letters almost always consume less than the full height of
the font.

And of course, in a more common situation, there are different types of
spacing between, say, your letter "a" and the bottom and top border of the
box where it resides: spacing cause by the fact that "a" is not as tall as
the height of the font; the leading, i.e. spacing caused by line-height
being larger than 1 as it usually is and should be; and padding, if set to a
nonzero value.

--
Yucca, http://www.cs.tut.fi/~jkorpela/

Nov 8 '08 #9

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

Similar topics

6
by: Rowland | last post by:
Hi, I've got a field that stores numeric values, representing a tracking number. I've also got a stored procedure that will extract this field and return it to a client. However, I would like to...
17
by: delerious | last post by:
I'm trying to add some simple padding to an IMG by using a padding-right style, but it doesn't work in IE. Works fine in Mozilla and Opera, though. Here's a link to a page which displays this IE...
5
by: Marita | last post by:
Hi, I have a page (several) where the top margin doesn't appear to be working. I have this in my code: <style type="text/css"> <!-- body { margin-left: 0px; margin-top: 0px; margin-right:...
15
by: I wish | last post by:
#include <string.h> int a; memset( a, 0, sizeof(a) ); Does that guarantee all bits zero? -- |
258
by: Terry Andersen | last post by:
If I have: struct one_{ unsigned int one_1; unsigned short one_2; unsigned short one_3; }; struct two_{ unsigned int two_1;
6
by: Army1987 | last post by:
Reliable sources (whose names I'm not allowed to disclose) told me that on the next version of the Deathstation (version 10000, or DS10K) an integral type (they didn't tell which) will have a odd...
1
by: Monte Cristo | last post by:
Hi all, I'm having a problem with results being returned from a data source, it's returning the right value but without the zero's "0" in front. I've searched through google for "padding zero's in...
6
by: john | last post by:
Many times I have seen padding bits being mentioned here. What is the purpose of the padding bits?
1
by: ags5406 | last post by:
i have a normal label with a fixed width font with no padding... lblsizing.Font {Name = "Lucida Console" Size=12.0} System.Drawing.Font lblsizing.Padding.All 0 Integer but despite the fact...
6
by: John Messenger | last post by:
I notice that the C standard allows padding bits in both unsigned and signed integer types. Does anyone know of any real-world examples of compilers that use padding bits? -- John
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.