How do you define attribute selectors in SASS?

83,106

Solution 1

You can also nest it like this

input
  &[type="submit"]
    .... 
  &[type="search"]
    .... 

Solution 2

This converter website says:

input[type=submit]
  // properties
Share:
83,106
gigimon
Author by

gigimon

Software Developer and Technology Consultant

Updated on October 05, 2021

Comments

  • gigimon
    gigimon over 2 years

    In CSS, you can do this:

    input[type=submit] {
      // properties
    }
    

    It's a very useful for styling form buttons.

    How do you do the same thing in SASS?

  • Jasper Kennis
    Jasper Kennis about 12 years
    I like this approach a lot since you'd often do this kind of thing to serve the right image from a sprite, in a toolbar or set of social links.
  • Terry Lin
    Terry Lin over 6 years
    Adding double quote doesn't work. This shouldn't be correct answer.
  • user3260487
    user3260487 over 5 years
    &[type='submit']
  • Marcelo Velasquez
    Marcelo Velasquez over 3 years
    The link is Broken
  • Alexander Ryan Baggett
    Alexander Ryan Baggett over 3 years
    Can someone put out a FULL and complete correct answer including some values being set?