Thursday, August 25, 2016

css with . and space difference



https://css-tricks.com/multiple-class-id-selectors/

Can you spot the difference between these two selectors?
#header.callout {  }

#header .callout { }
They look nearly identical, but the top one has no space between "#header" and ".callout" while the bottom one does. This small difference makes a huge difference in what it does. To some of you, that top selector may seem like a mistake, but it's actually a quite useful selector. Let's see the difference, what that top selector means, and exploring more of that style selector.
Here is the "plain English" of "#header .callout":
Select all elements with the class name callout that are decendents of the element with an ID of header.
Here is the "plain English" of "#header.callout":
Select the element which has an ID of header and also a class name of callout.
Maybe this graphic will make that more clear:

No comments:

Post a Comment