calculating specificity

Discussion in 'CSS' started by stephee24, Jul 12, 2007.

  1. #1
    What is the specificity of this selector?

    input[type="text"]

    I want to say 11 but the online specificity calculator I found says 10. Is that true? And if so, why isn't the input tag counted?
     
    stephee24, Jul 12, 2007 IP
  2. Dan Schulz

    Dan Schulz Peon

    Messages:
    6,032
    Likes Received:
    436
    Best Answers:
    0
    Trophy Points:
    0
    #2
    It targets input elements with a type of text, but it isn't supported by Internet Explorer (even version 7). It's best to apply a class name to the input element (like class="text") and target the class instead when styling input elements for text fields.

    Oh wait, you wanted the specificity of the selector. Since you're using it to target text fields, and as I said IE doesn't support it, it's best not to use it anyway and instead use the method I outlined above.
     
    Dan Schulz, Jul 13, 2007 IP
  3. stephee24

    stephee24 Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks Dan but I don't think you understand my question still. I am looking for theory not the best practice. I agree it's not a good idea to use an attribute selector because of the spotty support in IE. By the way, I have had luck getting IE7 to support input[type="text"] so you might want to double check your facts on that. Maybe it only works in certain contexts but it has worked for me.

    What I am interested in is the theory behind it. I want to know specifically, is the specificity of input[type="text"] 10 or 11. Anybody know? And if it is 10, as I found on one online specificity calculator, why isn't the input tag counted???
     
    stephee24, Jul 17, 2007 IP