CSS CSS Selectors Going Further with Attribute Selectors and Pseudo-Classes Substring Matching Attribute Selectors - "Begins With" and "Ends With"

Peter Retvari
Peter Retvari
Full Stack JavaScript Techdegree Student 8,392 Points

Don't ever use space after element when using pseudo classes

Guys,

I spent 25 minutes to figure it out what's wrong with my code ?

This is the good version:

a[href^="http:"] {

  color: #52bab3;
  text-decoration: none;
  background-repeat: no-repeat;
  background-size: 18px 18px;
  padding-left: 25px;

}

This is wrong:

a [href^="http:"] {

  color: #52bab3;
  text-decoration: none;
  background-repeat: no-repeat;
  background-size: 18px 18px;
  padding-left: 25px;

}

Hope it will help for some student

1 Answer

Diego ROJAS
Diego ROJAS
1,781 Points

You were trying to look for a child nested in an anchor tag in HTML.

Attaching or removing the space as you said now changes your selector to actually look for an anchor with a specific href.

It's tricky sometimes :D

Happy coding anyways

Peter Retvari
Peter Retvari
Full Stack JavaScript Techdegree Student 8,392 Points

Thanks Diego, yes you're right. It pretty looks like an anchor element:

a [href^="http:"]