I have simple code as below. I want set css red color for text aaa
. You can see i have set css for span
I thinked that only text aaa
will set red color, however css applied for both aaa
and bbb
. I don't understand it. Please explain it for me.
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<style>
#test > span {
color:red
}
</style>
</head>
<body>
<div id="test">
<span>aaa
<span>bbb</span>
</span>
</div>
</body>
</html>
try this css!
#test > span >span{
color:black;
}
#test > span{
color:red;
}
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<div id="test">
<span>aaa
<span>bbb</span>
</span>
</div>
</body>
</html>
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments