Do CSS rules exist for placing content such as images or text within elements?
eg. say I have a div which can contain some info which is correct and some info which is wrong, can I have rules such as:
.correct {
img: greenTick.jpg;
text: "answer is wrong"
}
.wrong {
img: redX.jpg;
text: "answer is correct"
}
Is it possible to position them too?
CSS
background-image
attribute would be the one that you need to use insteadimg
. See below an example of how to do it with your both style classes:You can use pseudo elements (
::before
and::after
). Set the text using thecontent
attribute, and the image as the background of the pseudo element or thediv
: