centred text / css selector precedence

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • martin.eyles@ntlworld.com

    centred text / css selector precedence

    I am having a problem with this page:-



    I want a nice centred paragraph, but get a justified paragraph. I
    expected the .centre to override the #content p, as it is later in the
    css file, but it doesn't.

    The reason I have both these rules in the css is because in general
    paragraphs in the content section of our pages should be justified, but
    some are centred instead, so get their own class.

    Thankyou for your help,

    Martin

    --
    Martin Eyles
    martin.eyles@NO SPAMbytronic.co m
    (posting as martin.eyles@NO SPAMntlworld.co m from google because the
    news server is down)

  • David Dorward

    #2
    Re: centred text / css selector precedence

    martin.eyles@nt lworld.com wrote:
    [color=blue]
    > I want a nice centred paragraph, but get a justified paragraph. I
    > expected the .centre to override the #content p, as it is later in the
    > css file, but it doesn't.[/color]

    #content p is more specific then .centre so it takes priority.

    #content p = 101
    ..centre = 010



    --
    David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is

    Comment

    • Adam Risser

      #3
      Re: centred text / css selector precedence

      Im not sure why it doesnt overwrite the first style, but if you do
      this:

      .centre {text-align: center !important; }

      it will use that rule instead.


      Adam


      Comment

      • Martin Eyles

        #4
        Re: centred text / css selector precedence

        "David Dorward" <dorward@yahoo. com> wrote[color=blue]
        > http://www.w3.org/TR/CSS2/cascade.html#specificity[/color]

        Thank you for explaining why this happens...

        --
        Martin Eyles
        martin.eyles@NO SPAM.bytronic.c om
        (yay, the news server be fixed)


        Comment

        • Martin Eyles

          #5
          Re: centred text / css selector precedence

          "Adam Risser" <arisser@gmail. com> wrote[color=blue]
          > .centre {text-align: center !important; }[/color]

          .... and thank you for explaining how to fix it.

          --
          Martin Eyles
          martin.eyles@NO SPAM.bytronic.c om
          (yay, the news server be fixed)


          Comment

          • Stuart Scharf

            #6
            Re: centred text / css selector precedence

            Adam Risser wrote:[color=blue]
            > Im not sure why it doesnt overwrite the first style, but if you do
            > this:
            >
            > .centre {text-align: center !important; }
            >
            > it will use that rule instead.
            >
            >
            > Adam
            > http://www.adamrisser.com
            >[/color]

            or depending on how you want to structure things add

            #content p.centre {text-align: center}

            Stuart

            Comment

            • Jasen Betts

              #7
              Re: centred text / css selector precedence

              On 2005-12-22, Adam Risser <arisser@gmail. com> wrote:[color=blue]
              > Im not sure why it doesnt overwrite the first style, but if you do
              > this:
              >
              > .centre {text-align: center !important; }
              >
              > it will use that rule instead.[/color]

              I thought !important meant "not important" to IE.


              Bye.
              Jasen

              Comment

              Working...