I have this code:
<html>
<head>
<title>Document Title</title>
</head>
<body>
<div style="border:1px solid black;"
style="background-color: green !important;">
Test Text
</div>
</body>
</html>
The border exists as specified. However, the background of the div is not green. Why is the background of the div not green?
I know this is basic, but I've been reading for hours and I can't find an answer anywhere.
Use one style attribute. Also, you don't need !important
, inline styles always have highest priority.
<div style="border:1px solid black; background-color: green;"> Test Text </div>
you should use only one style in your codding to acheive property of CSS.
here the code;
enter code here
<!doctype html>
<html>
<head>
<title>Document Title</title>
</head>
<body>
<div style="border:1px solid black;background-color: green;">
Test Text
</div>
</body>
</html>
You can only have one style attribute per element so the second one is being ignored. Just combine them:
<div style="border:1px solid black;background-color: green !important;">
Test Text
</div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.