<body bgcolor="#FF0000">
body {background-color: #FF0000;}
selector {
property: value;
property2: value;
/* other rules */
}
p {
/* ... */
}
h1 {
property: url("http://google.com");
property: 0.7;
property: 90%;
property: #ff0000;
property: rgb(255, 0, 0);
property: uppercase;
}
<p id="main" class="text paragraph"
data-color="green">Dummy text</p>
#main {...}
.text {...}
p {...}
p.text {...}
.text.paragraph {...}
p[data-color="green"] {
color: green;
}
<body style="background-color: #FF0000;">
<p>This is a red page</p>
</body>
<p style="color: #D00; font-size: 22px;">Dummy text</p>
<style type="text/css">
body {background-color: #FF0000;}
</style>
<link rel="stylesheet" type="text/css" href="style/style.css" />
@import "style-1.css";
@import url("style-2.css");
id for identification,
class for grouping
#welcome-page { .. }
.section { .. }
.section#welcome { ... }
.section.otherClass.oneMoreOtherClass { ... }
a { .. }
ul { .. }
content
[attribute] { ... }
selector[attribute] { .. }
[attribute="value"] { ... }
selector[attribute1="value1"][attribute2="value2"].. { .. }
#container + p {
color: red;
}
#container ~ li {
background: blue;
}
#container > p {
font-size: 30px;
}
selector::after {
content: 'text';
}
background: color image position/size repeat
origin clip attachment initial|inherit;
* {
color: red;
}
#container * {
color: red;
}
div { height: 200px; width: 200px; }
.blue { background-color: blue; }
.box { background-color: red; }
div { height: 200px; width: 200px; }
#box { background-color: red; }
.blue { background-color: blue; }
https://jsfiddle.net/Lwr9o23a/
https://jsfiddle.net/Lwr9o23a/1/
!important
table td {height: 50px !important;}
.myTable td {height: 50px !important;}
#myTable td {height: 50px !important;}
Relative units: em, rem, ex, px, %
Absolute units: in, cm, mm, pt, pc
https://jsfiddle.net/gubtxyof/6/
* {
box-sizing: border-box;
}
.element {
position: static; /* default */
position: relative;
position: absolute;
position: fixed;
position: sticky;
}
.element {
float: left;
}
.element {
float: right;
}
http://arvindr21.github.io/howBrowserWorks
http://www.html5rocks.com/ru/tutorials/internals/howbrowserswork/
.element {
float: left;
}
.element {
float: left;
}
.footer {
clear: both;
float: none;
}
.clearfix:after {
visibility: hidden;
display: block;
font-size: 0;
content: " ";
clear: both;
height: 0;
}
.clearfix { display: inline-block; }
* html .clearfix { height: 1%; }
.clearfix { display: block; }