Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

SASS: BEM –pink to a P element

I’ve delcared my modifier to the P element as per below. In HTML (at the bottom), what am I doing incorrectly as the p tags do not change to pink if I declare the class name as shown.

p {
    font-size: 1rem;

    &--pink{
        color: pink;
    }
}
  <p class="block__p --pink">this is placeholder text.</p>

I thought it was a simple spacing error from the p to the " –pink" but that makes no difference to the outcome.

  <p class="block__p--pink">this is placeholder text.</p>

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The correct selector for a <p> tag with a class of --pink is p.--pink. You are missing the . (class selector).

p {
  font-size: 1rem;

  &.--pink{
    color: pink;
  }
}

See it working.

I recommend The Sass Playground, which allows you to see in real time the CSS output of your SCSS.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading