EN
CSS - overwrite style
0 points
In this article, we would like to show you how to overwrite style in CSS.
Quick solution:
xxxxxxxxxx
1
div {
2
background: blue; /* common style */
3
}
Use inline style to overwrite the common style:
xxxxxxxxxx
1
<div style="background: orange;">Background changed.</div>
In this example, we use the inline style to overwrite the div
element's background
color.
xxxxxxxxxx
1
2
<html>
3
<head>
4
<style>
5
6
body {
7
display: flex;
8
}
9
10
div {
11
height: 75px;
12
width: 75px;
13
text-align: center;
14
background: deepskyblue;
15
border: 1px solid black;
16
}
17
18
</style>
19
</head>
20
<body>
21
<div>div-1</div>
22
<div>div-2</div>
23
<div style="background: orange;">div-3</div>
24
<div>div-4</div>
25
</body>
26
</html>