Attribute selector help.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • -Lost

    Attribute selector help.

    Alright, it has been a *long* time since I read a CSS spec, so here is my question(s).

    1. I have seen styles like this:

    element#idName[id]

    What does the "[id]" part do? I mean, it is already inside an element with an ID of
    "idName" so why is the attribute included? Is it doing something that I am just not aware
    of?

    2. How could I apply a style to all Ps with an ID of fn? n being a number from 1 to
    whatever.

    I thought that:

    p[id~="f"]

    ....would do it, but apparently not.

    Thanks.

    -Lost


  • Chris Vogel

    #2
    Re: Attribute selector help.

    -Lost wrote:
    Alright, it has been a *long* time since I read a CSS spec, so here
    is my question(s).
    Then you should probably read it again. All your answers are there.


    2. How could I apply a style to all Ps with an ID of fn? n being
    a number from 1 to whatever.
    >
    I thought that:
    >
    p[id~="f"]
    >
    ...would do it, but apparently not.
    You just have to list them all out separately.

    #f1,#f2,#f3,...
    {
    color: red;
    }

    Maybe you should be using classes?

    Comment

    • -Lost

      #3
      Re: Attribute selector help.

      "Chris Vogel" <chris@chrisvog el.namewrote in message
      news:SaPrh.7833 $O53.892@bignew s6.bellsouth.ne t...
      -Lost wrote:
      >Alright, it has been a *long* time since I read a CSS spec, so here
      > is my question(s).
      >
      Then you should probably read it again. All your answers are there.
      >
      http://www.w3.org/TR/REC-CSS2/selector.html
      I imagine I worded that incorrectly. My point was that I did not understand it (or I
      thought I might not understand it fully).

      I have it sorted now.
      >2. How could I apply a style to all Ps with an ID of fn? n being
      >a number from 1 to whatever.
      >>
      >I thought that:
      >>
      >p[id~="f"]
      >>
      >...would do it, but apparently not.
      >
      You just have to list them all out separately.
      >
      #f1,#f2,#f3,...
      {
      color: red;
      }
      >
      Maybe you should be using classes?
      Yeah, that is what I was currently using. Was not sure if there was another method to
      just point at IDs (since they were mandatory, classes were not).

      Thanks all the same.

      -Lost


      Comment

      Working...