Body tag vs margin-right

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Terry Moon

    Body tag vs margin-right

    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 ?



    --



  • Jukka K. Korpela

    #2
    Re: Body tag vs margin-right

    Terry Moon wrote:
    [color=blue]
    > I was using <BODY leftmargin=20 > which worked ok.[/color]

    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.
    [color=blue]
    > but then I changed it to
    > <BODY style="margin-left:20px;" and this works fine as well.[/color]

    For different values of "worked". It does something on supporting
    browsers with CSS enabled, assuming that no other style sheet overrides it.
    [color=blue]
    > 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.[/color]

    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.
    [color=blue]
    > .. in my page now the body tag has no attributes apart from one.
    >
    > <BODY vlink="blue" >[/color]

    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.
    [color=blue]
    > and in the linked style sheet/
    >
    > BODY { margin-left:20px }[/color]

    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.
    [color=blue]
    > What am I doing wrong ?[/color]

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

    Comment

    • Terry Moon

      #3
      Re: Body tag vs margin-right

      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@cs.tu t.fi> wrote in message
      news:dqtf8q$83k $1@phys-news4.kolumbus. fi...[color=blue]
      > Terry Moon wrote:
      >[color=green]
      >> I was using <BODY leftmargin=20 > which worked ok.[/color]
      >
      > 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.
      >[color=green]
      >> but then I changed it to <BODY style="margin-left:20px;" and this works
      >> fine as well.[/color]
      >
      > For different values of "worked". It does something on supporting browsers
      > with CSS enabled, assuming that no other style sheet overrides it.
      >[color=green]
      >> 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.[/color]
      >
      > 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.
      >[color=green]
      >> .. in my page now the body tag has no attributes apart from one.
      >>
      >> <BODY vlink="blue" >[/color]
      >
      > 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.
      >[color=green]
      >> and in the linked style sheet/
      >>
      >> BODY { margin-left:20px }[/color]
      >
      > 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.
      >[color=green]
      >> What am I doing wrong ?[/color]
      >
      > You are not showing the URL to us, to begin with.[/color]


      Comment

      • Stan Brown

        #4
        Re: Body tag vs margin-right

        Sat, 21 Jan 2006 16:08:47 +0200 from Jukka K. Korpela
        <jkorpela@cs.tu t.fi>:[color=blue]
        > Terry Moon wrote:[color=green]
        > > <BODY style="margin-left:20px;" and this works fine as well.[/color]
        >
        > For different values of "worked". It does something on supporting
        > browsers with CSS enabled, assuming that no other style sheet overrides it.[/color]

        _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
        Portal Live Casino Terbaik di DRAGON222! Nikmati taruhan game spesialis Baccarat dan roulette resmi. Mengajak mencari pengalaman bermain yang lebih seru secara online tanpa harus dateng ke casino offline.

        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:

        Comment

        • Michael Winter

          #5
          Re: Body tag vs margin-right

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

          [snip]
          [color=blue]
          > _Could_ any other style sheet override it? I thought an inline style
          > always overrides any attached or embedded sheet.[/color]

          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.

          Comment

          • Jukka K. Korpela

            #6
            Re: Body tag vs margin-right

            Michael Winter <m.winter@bluey onder.co.uk> wrote:
            [color=blue][color=green]
            >> _Could_ any other style sheet override it? I thought an inline style
            >> always overrides any attached or embedded sheet.[/color]
            >
            > An in-line style declaration is more specific than any other selector,
            > so an author style sheet couldn't override it.[/color]

            An author style sheet can override it by using !important.
            [color=blue]
            > However, a user style sheet could.[/color]

            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/

            Comment

            • Jukka K. Korpela

              #7
              Re: Body tag vs margin-right

              "Terry Moon" <TerryMoon@hotm ail.co.uk> wrote:
              [color=blue]
              > Thanks for your reply.[/color]

              Please learn to quote properly on Usenet:

              [color=blue]
              > 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 ?[/color]

              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/

              Comment

              • Michael Winter

                #8
                Re: Body tag vs margin-right

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

                [snip]
                [color=blue]
                > An author style sheet can override [an in-line declaration] by using
                > !important.[/color]

                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.

                Comment

                • Spartanicus

                  #9
                  Re: Body tag vs margin-right

                  "Jukka K. Korpela" <jkorpela@cs.tu t.fi> wrote:
                  [color=blue][color=green]
                  >> An in-line style declaration is more specific than any other selector,
                  >> so an author style sheet couldn't override it.[/color]
                  >
                  >An author style sheet can override it by using !important.[/color]

                  Nope.

                  --
                  Spartanicus

                  Comment

                  • Jukka K. Korpela

                    #10
                    Re: Body tag vs margin-right

                    Spartanicus <invalid@invali d.invalid> wrote:
                    [color=blue]
                    > "Jukka K. Korpela" <jkorpela@cs.tu t.fi> wrote:
                    >[color=green][color=darkred]
                    >>> An in-line style declaration is more specific than any other selector,
                    >>> so an author style sheet couldn't override it.[/color]
                    >>
                    >>An author style sheet can override it by using !important.[/color]
                    >
                    > Nope.[/color]

                    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/

                    Comment

                    • Spartanicus

                      #11
                      Re: Body tag vs margin-right

                      "Jukka K. Korpela" <jkorpela@cs.tu t.fi> wrote:
                      [color=blue][color=green][color=darkred]
                      >>>> 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.[/color]
                      >>
                      >> Nope.[/color]
                      >
                      >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?[/color]

                      I initially checked to make sure with a quick test case, I must have
                      goofed when creating it, I couldn't repeat the result when I re-created
                      the test, apologies.

                      --
                      Spartanicus

                      Comment

                      • Stan Brown

                        #12
                        Re: Body tag vs margin-right

                        Sat, 21 Jan 2006 11:27:08 -0500 from Stan Brown
                        <the_stan_brown @fastmail.fm>:[color=blue]
                        > Sat, 21 Jan 2006 16:08:47 +0200 from Jukka K. Korpela
                        > <jkorpela@cs.tu t.fi>:[color=green]
                        > > Terry Moon wrote:[color=darkred]
                        > > > <BODY style="margin-left:20px;" and this works fine as well.[/color]
                        > >
                        > > For different values of "worked". It does something on supporting
                        > > browsers with CSS enabled, assuming that no other style sheet overrides it.[/color]
                        >
                        > _Could_ any other style sheet override it? I thought an inline style
                        > always overrides any attached or embedded sheet.[/color]

                        As several people pointed out, I forgot about !important. Thanks.

                        --
                        Stan Brown, Oak Road Systems, Tompkins County, New York, USA
                        Portal Live Casino Terbaik di DRAGON222! Nikmati taruhan game spesialis Baccarat dan roulette resmi. Mengajak mencari pengalaman bermain yang lebih seru secara online tanpa harus dateng ke casino offline.

                        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:

                        Comment

                        • Dan Rumney

                          #13
                          Re: Body tag vs margin-right

                          > If this does not work and <BODY style="margin-left:20px;"> works, then[color=blue]
                          > you have
                          > a) an error in your HTML markup
                          > b) an error elsewhere in the style sheet
                          > c) a faulty browser.
                          >[color=green]
                          >> What am I doing wrong ?[/color]
                          >
                          > You are not showing the URL to us, to begin with.[/color]

                          There is a more prosaic possibility: that your link to the stylesheet is
                          incorrect somehow.

                          Again, post your URL and someone on the newsgroup would very quickly be
                          able to tell you if this is the case

                          Dan

                          Comment

                          Working...