EN
CSS - overwrite style
0
points
In this article, we would like to show you how to overwrite style in CSS.
Quick solution:
div {
background: blue; /* common style */
}
Use inline style to overwrite the common style:
<div style="background: orange;">Background changed.</div>
Practical example
In this example, we use the inline style to overwrite the div
element's background
color.
// ONLINE-RUNNER:browser;
<!doctype html>
<html>
<head>
<style>
body {
display: flex;
}
div {
height: 75px;
width: 75px;
text-align: center;
background: deepskyblue;
border: 1px solid black;
}
</style>
</head>
<body>
<div>div-1</div>
<div>div-2</div>
<div style="background: orange;">div-3</div>
<div>div-4</div>
</body>
</html>