HighDots Forums  

Body tag vs margin-right

Cascading Style Sheets Layout/presentation on the WWW (comp.infosystems.www.authoring.stylesheets)


Discuss Body tag vs margin-right in the Cascading Style Sheets forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Terry Moon
 
Posts: n/a

Default Body tag vs margin-right - 01-21-2006 , 08:23 AM






Hi

I was using <BODY leftmargin=20 > which worked ok. but then I changed it to
<BODY style="margin-left:20px;" and this works fine as well.

In order to try and formalise things I decided to use a style sheet so I
linked it in and every other style i have set works fine. but my margin for
the entire page does not work.

... in my page now the body tag has no attributes apart from one.

<BODY vlink="blue" >

and in the linked style sheet/

BODY { margin-left:20px }


What am I doing wrong ?



--




Reply With Quote
  #2  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: Body tag vs margin-right - 01-21-2006 , 09:08 AM






Terry Moon wrote:

Quote:
I was using <BODY leftmargin=20 > which worked ok.
For some odd values of "worked". It is proprietary markup that is
supported by some browsers only, so you didn't test well. Besides, it
sets the margin in pixels, not relative to font size.

Quote:
but then I changed it to
BODY style="margin-left:20px;" and this works fine as well.
For different values of "worked". It does something on supporting
browsers with CSS enabled, assuming that no other style sheet overrides it.

Quote:
In order to try and formalise things I decided to use a style sheet so I
linked it in and every other style i have set works fine.
That's a good idea, especially since doing things in such a centralized
manner lets you fix errors more easily when you notice that e.g. wasting
20 pixels on the left is not that fine.

Quote:
.. in my page now the body tag has no attributes apart from one.

BODY vlink="blue"
That's _very_ poor practice. Never touch a color without setting other
colors, and never set visited link color to the common default color of
unvisited links. But this has nothing to do with margins.

Quote:
and in the linked style sheet/

BODY { margin-left:20px }
If this does not work and <BODY style="margin-left:20px;"> works, then
you have
a) an error in your HTML markup
b) an error elsewhere in the style sheet
c) a faulty browser.

Quote:
What am I doing wrong ?
You are not showing the URL to us, to begin with.


Reply With Quote
  #3  
Old   
Terry Moon
 
Posts: n/a

Default Re: Body tag vs margin-right - 01-21-2006 , 10:08 AM



Thanks for your reply.

One more question if you dont mind please?

Do the nested tags inherit the enclosing tag style attributes, for example,
if the body tag had a margin-left:nn then would all paragraphs enclosed
therin also have this margin by default ?

--

"Jukka K. Korpela" <jkorpela (AT) cs (DOT) tut.fi> wrote

Quote:
Terry Moon wrote:

I was using <BODY leftmargin=20 > which worked ok.

For some odd values of "worked". It is proprietary markup that is
supported by some browsers only, so you didn't test well. Besides, it sets
the margin in pixels, not relative to font size.

but then I changed it to <BODY style="margin-left:20px;" and this works
fine as well.

For different values of "worked". It does something on supporting browsers
with CSS enabled, assuming that no other style sheet overrides it.

In order to try and formalise things I decided to use a style sheet so I
linked it in and every other style i have set works fine.

That's a good idea, especially since doing things in such a centralized
manner lets you fix errors more easily when you notice that e.g. wasting
20 pixels on the left is not that fine.

.. in my page now the body tag has no attributes apart from one.

BODY vlink="blue"

That's _very_ poor practice. Never touch a color without setting other
colors, and never set visited link color to the common default color of
unvisited links. But this has nothing to do with margins.

and in the linked style sheet/

BODY { margin-left:20px }

If this does not work and <BODY style="margin-left:20px;"> works, then you
have
a) an error in your HTML markup
b) an error elsewhere in the style sheet
c) a faulty browser.

What am I doing wrong ?

You are not showing the URL to us, to begin with.



Reply With Quote
  #4  
Old   
Stan Brown
 
Posts: n/a

Default Re: Body tag vs margin-right - 01-21-2006 , 11:27 AM



Sat, 21 Jan 2006 16:08:47 +0200 from Jukka K. Korpela
<jkorpela (AT) cs (DOT) tut.fi>:
Quote:
Terry Moon wrote:
BODY style="margin-left:20px;" and this works fine as well.

For different values of "worked". It does something on supporting
browsers with CSS enabled, assuming that no other style sheet overrides it.
_Could_ any other style sheet override it? I thought an inline style
always overrides any attached or embedded sheet.

--
Stan Brown, Oak Road Systems, Tompkins County, New York, USA
http://OakRoadSystems.com/
HTML 4.01 spec: http://www.w3.org/TR/html401/
validator: http://validator.w3.org/
CSS 2.1 spec: http://www.w3.org/TR/CSS21/
validator: http://jigsaw.w3.org/css-validator/
Why We Won't Help You:
http://diveintomark.org/archives/200..._wont_help_you


Reply With Quote
  #5  
Old   
Michael Winter
 
Posts: n/a

Default Re: Body tag vs margin-right - 01-21-2006 , 11:51 AM



On 21/01/2006 16:27, Stan Brown wrote:

[snip]

Quote:
_Could_ any other style sheet override it? I thought an inline style
always overrides any attached or embedded sheet.
An in-line style declaration is more specific than any other selector,
so an author style sheet couldn't override it. However, a user style
sheet could.

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.


Reply With Quote
  #6  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: Body tag vs margin-right - 01-21-2006 , 12:03 PM



Michael Winter <m.winter (AT) blueyonder (DOT) co.uk> wrote:

Quote:
_Could_ any other style sheet override it? I thought an inline style
always overrides any attached or embedded sheet.

An in-line style declaration is more specific than any other selector,
so an author style sheet couldn't override it.
An author style sheet can override it by using !important.

Quote:
However, a user style sheet could.
By using !important, as a user style sheet would have to do to override any
declaration in an author style sheet.

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


Reply With Quote
  #7  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: Body tag vs margin-right - 01-21-2006 , 12:08 PM



"Terry Moon" <TerryMoon (AT) hotmail (DOT) co.uk> wrote:

Quote:
Thanks for your reply.
Please learn to quote properly on Usenet:
http://www.netmeister.org/news/learn2quote.html

Quote:
Do the nested tags inherit the enclosing tag style attributes, for
example, if the body tag had a margin-left:nn then would all paragraphs
enclosed therin also have this margin by default ?
Tags inherit nothing. Elements may inherit properties, but margin properties
are not inherited. Thus, setting margin-left for the body element affects
that element only.

On the other hand, the paragraphs (p elements) are descendents of the body
element, so they normally appear inside the block generated for the body
element - and this block has the margins assigned for the body element.

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


Reply With Quote
  #8  
Old   
Michael Winter
 
Posts: n/a

Default Re: Body tag vs margin-right - 01-21-2006 , 12:11 PM



On 21/01/2006 17:03, Jukka K. Korpela wrote:

[snip]

Quote:
An author style sheet can override [an in-line declaration] by using
!important.
Yes, of course. Sorry. It would be a silly thing to force oneself to do,
though.

[snip]

Mike

--
Michael Winter
Prefix subject with [News] before replying by e-mail.


Reply With Quote
  #9  
Old   
Spartanicus
 
Posts: n/a

Default Re: Body tag vs margin-right - 01-21-2006 , 12:25 PM



"Jukka K. Korpela" <jkorpela (AT) cs (DOT) tut.fi> wrote:

Quote:
An in-line style declaration is more specific than any other selector,
so an author style sheet couldn't override it.

An author style sheet can override it by using !important.
Nope.

--
Spartanicus


Reply With Quote
  #10  
Old   
Jukka K. Korpela
 
Posts: n/a

Default Re: Body tag vs margin-right - 01-21-2006 , 01:45 PM



Spartanicus <invalid (AT) invalid (DOT) invalid> wrote:

Quote:
"Jukka K. Korpela" <jkorpela (AT) cs (DOT) tut.fi> wrote:

An in-line style declaration is more specific than any other selector,
so an author style sheet couldn't override it.

An author style sheet can override it by using !important.

Nope.
Please check http://www.w3.org/TR/REC-CSS2/cascade.html#cascade
The _primary_ sort is by weight and origin. Only when this does not resolve
the issue, specificity will be considered.

Did you try it?

<style type="text/css">
body { margin: 0 !important; }
</style>
<body style="margin-left:20px">

By CSS specs, you should get zero margins. And even IE obeys this.

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


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.