Question

I have a HTML of <span> Day Month </span>

and for CSS I want to target Day seperately and Month seperately (apply different styles to them) without changing the HTML.

How can I do it?

Était-ce utile?

La solution

Yeah its possible. You can follow this method. Here font-word is not posible, that have no option in css. But we use content css property

<!DOCTYPE html>
<html>
<head>
<style>
span {
color: orange;
    }
span:before
{
color: red;
content: "Day";
position: absolute;
}
</style>
</head>
<body>
<span>Day Month </span>
</body>
</html>

Updated: Here the fiddle Demo

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top