I have some code where I’m using pseudo-elements to hold some background icons:
.icon:before {
content: '';
display: block;
width: 16px;
height: 16px;
background: url(star.png);
}
I also have some code where I’m not using pseudo-elements, but simply adding the icon directly within a tag:
span {
display: block;
width: 16px;
height: 16px;
background: url(star.png);
}
The only difference between the two code blocks is the pseudo-element needs an empty “content” property, while the non-pseudo doesn’t.
So, for the sake of not having to repeat myself throughout the code, would it be ok to just do the following:
.icon:before, span {
content: '';
display: block;
width: 16px;
height: 16px;
background: url(star.png);
}
and not worry about the ‘span’ applying (or not applying) the ‘content’ property, because it’s only specific to pseudo-elements?
I know I can just isolate the ‘.icon:before’ and apply the content property there, but I’m creating alot of this code in a SASS loop and don’t want to get too far into the weeds spending time trying to separate them if it’s not necessary to do so.
Thanks.