default properties of tags

G

Gregor Traven

Hi

This is what happened to me. I was using css to define the body tag. So I
left the tag in html file empty like this: <body>. In my css I defined
margin for this body but if I had for example 20px of margin, the displayed
website in a browser showed 21px I think.Anyways more than 20px as if there
was one px added to those twenty though it wasn't declared anywhere. After a
few tries I found out that if I declare <body topmargin="0"> in html, the 20
px from css remain the 20px that I wanted.
It was the same with tables, if I didn't put cellspacing="0" in html tag,
there was at least 1 px of spacing when displayed in a browser.
My question is: are there such things as default values for tags which would
explain this strange behaviour? I used Internet Explorer and Opera and both
shwed the same.

Thanks for answering

Gregor
 
B

brucie

in post: <
Gregor Traven said:
In my css I defined margin for this body but if I had for example 20px
of margin, the displayed website in a browser showed 21px

stop your gowd damn complaining. theres a starving child in africa
somewhere who would love to have a pixel and you're complaining you have
ONE too many.
are there such things as default values for tags

which would explain this strange behaviour?

sorry, i gave my crystal ball to a staving african child.
 
N

Neal

Hi

This is what happened to me. I was using css to define the body tag. So I
left the tag in html file empty like this: <body>. In my css I defined
margin for this body but if I had for example 20px of margin, the
displayed
website in a browser showed 21px I think.Anyways more than 20px as if
there
was one px added to those twenty though it wasn't declared anywhere.
After a
few tries I found out that if I declare <body topmargin="0"> in html,
the 20
px from css remain the 20px that I wanted.
It was the same with tables, if I didn't put cellspacing="0" in html tag,
there was at least 1 px of spacing when displayed in a browser.
My question is: are there such things as default values for tags which
would
explain this strange behaviour? I used Internet Explorer and Opera and
both
shwed the same.

Thanks for answering

Gregor

I can't address the specifics of your roghe pixel, but see this:

http://www.w3.org/TR/CSS21/sample.html
 
D

DU

Gregor said:
Hi

This is what happened to me. I was using css to define the body tag. So I
left the tag in html file empty like this: <body>. In my css I defined
margin for this body but if I had for example 20px of margin, the displayed
website in a browser showed 21px I think.Anyways more than 20px as if there
was one px added to those twenty though it wasn't declared anywhere. After a
few tries I found out that if I declare <body topmargin="0"> in html, the 20
px from css remain the 20px that I wanted.

I recommend not to use invalid or deprecated attributes like that. When
you're facing a particular problem or issue, search or investigate the
default css values for the browser and in general you'll find the
values. There is no modern browser which does not allow web authors to
know these default values.
It was the same with tables, if I didn't put cellspacing="0" in html tag,
there was at least 1 px of spacing when displayed in a browser.
My question is: are there such things as default values for tags which would
explain this strange behaviour? I used Internet Explorer and Opera and both
shwed the same.

Thanks for answering

Gregor

MSIE 6 for windows in standards compliant rendering mode will render a
border around the body with the following (browser default) value:

html {medium #000000 inset}

Thus your 1px.

Important and unknown default browser values
http://www10.brinkster.com/doctorunclear/HTMLJavascriptCSS/BrowsersDefaultValues.html

DU
 
J

Jukka K. Korpela

DU said:
When you're facing a particular problem or issue, search or
investigate the default css values for the browser and in general
you'll find the values. There is no modern browser which does not
allow web authors to know these default values.

I hadn't realized that such values can be found using some JavaScript as
you do on your page - but I had to find out the method by reading your
source code, and I'm afraid most authors are quite unaware of such
possibilities. Besides, most authors would find it very difficult to use
such methods without any simple tools. And how do we know which values to
look for? For example, spacing somewhere might be caused by some margin,
or some padding, or some border.
MSIE 6 for windows in standards compliant rendering mode will render
a border around the body with the following (browser default) value:

html {medium #000000 inset}

You apparently meant
html {border: medium #000000 inset}
(which is technically a border around the root element, <html>, not the
body element).

But how did you get at that conclusion? I have tried to describe what
really happens in "quirks" versus "standard" mode on
MSIE 6 - most documentation of what I had seen was hopelessly incomplete
- but I did not catch that particular oddity. The oddity nicely reflects
that "standard" mode is just a different rendering mode - the name is
misleading, though MSIE 6 admittedly violates W3C specifications
less in "standard" mode than in "quirks" mode. There is absolutely
nothing in HTML or CSS specifications that says that the root element
shall (or even should) have some border by default - and naturally no
prohibition either.
Thus your 1px.

What puzzles me is that for border-width, MSIE treats medium as 4px.
And in fact, if I explicitly set
html { border-width: medium; }
the effect differs from the default. (This is easier to see if you also
set border-color to red, for example.)
Important and unknown default browser values
http://www10.brinkster.com/doctorunclear/HTMLJavascriptCSS/BrowsersDef
aultValues.html

Interesting information, but it displays just small part of all the
defaults - and can we trust the information derived from what we get by
printing components of currentStyle? The example suggests otherwise,
unless I'm mistaken.
 
D

DU

Jukka said:
I hadn't realized that such values can be found using some JavaScript as
you do on your page - but I had to find out the method by reading your
source code, and I'm afraid most authors are quite unaware of such
possibilities. Besides, most authors would find it very difficult to use
such methods without any simple tools. And how do we know which values to
look for?

Good question. Searching, experimentation, empirical deductions.

For example, spacing somewhere might be caused by some margin,
or some padding, or some border.




You apparently meant
html {border: medium #000000 inset}
(which is technically a border around the root element, <html>, not the
body element).

But how did you get at that conclusion? I have tried to describe what
really happens in "quirks" versus "standard" mode on
MSIE 6 - most documentation of what I had seen was hopelessly incomplete


Incomplete and sometimes incorrect. The DHTML object model is another
one with inaccuracies, even contradictions. The documentation on MSIE on
these issues would certainly benefit from a general and thorough
clarification.
- but I did not catch that particular oddity. The oddity nicely reflects
that "standard" mode is just a different rendering mode - the name is
misleading, though MSIE 6 admittedly violates W3C specifications
less in "standard" mode than in "quirks" mode. There is absolutely
nothing in HTML or CSS specifications that says that the root element
shall (or even should) have some border by default - and naturally no
prohibition either.




What puzzles me is that for border-width, MSIE treats medium as 4px.
And in fact, if I explicitly set
html { border-width: medium; }
the effect differs from the default. (This is easier to see if you also
set border-color to red, for example.)

Yes, I see what you mean. I can't explain this right now. I even tried
html {medium #000000 inset}
and I do not get the default. :)
I do mention "including a default standard border black inset 1px
border" instead in another page of my site, not medium.
Interesting information, but it displays just small part of all the
defaults - and can we trust the information derived from what we get by
printing components of currentStyle? The example suggests otherwise,
unless I'm mistaken.

I agree. We can't trust these info. I need to investigate this furthermore.

Thanks

DU
 
D

DU

Jukka said:
I hadn't realized that such values can be found using some JavaScript as
you do on your page - but I had to find out the method by reading your
source code, and I'm afraid most authors are quite unaware of such
possibilities. Besides, most authors would find it very difficult to use
such methods without any simple tools. And how do we know which values to
look for? For example, spacing somewhere might be caused by some margin,
or some padding, or some border.




You apparently meant
html {border: medium #000000 inset}
(which is technically a border around the root element, <html>, not the
body element).

But how did you get at that conclusion? I have tried to describe what
really happens in "quirks" versus "standard" mode on
MSIE 6 - most documentation of what I had seen was hopelessly incomplete
- but I did not catch that particular oddity. The oddity nicely reflects
that "standard" mode is just a different rendering mode - the name is
misleading, though MSIE 6 admittedly violates W3C specifications
less in "standard" mode than in "quirks" mode. There is absolutely
nothing in HTML or CSS specifications that says that the root element
shall (or even should) have some border by default - and naturally no
prohibition either.




What puzzles me is that for border-width, MSIE treats medium as 4px.
And in fact, if I explicitly set
html { border-width: medium; }
the effect differs from the default. (This is easier to see if you also
set border-color to red, for example.)




Interesting information, but it displays just small part of all the
defaults - and can we trust the information derived from what we get by
printing components of currentStyle? The example suggests otherwise,
unless I'm mistaken.

I checked with Zvon's Javascript DOM factory for non-empty CSS2
declarations on the root element for style, currentStyle and
runtimeStyle objects and the values are the same for currentStyle:
border {medium #000000 inset}

Using MSIE 6,
http://www.zvon.org/xxl/JSDOMFactory/ie/novice2.html
URI to load: http://www.zvon.org/
Object lookup: document.documentElement.currentStyle
View filter: non empty
CSS2 radio button checked

So, it's somewhat a mystery; for sure, 1px != 4px

DU
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top