<body>
<section>
<h2>Подписаться на рассылку:</h2>
<p>После вашего согласия вам будут приходить уведомления</p>
<form class="main">
<div class="field">
<label for="name" class="check-label">Ваше Имя</label>
<input type="text"
id="name"
placeholder="Имя"
class="filled">
</div>
</form>
</section>
</body>
<html>
<ul>
<li></li>
<li></li>
<li>
<ul>
<li></li>
<li></li>
</ul>
<ul>
<li></li>
</ul>
</li>
</ul>
<p></p>
</html>
<a href="/" class="red">На главную</a>
<div class="info">
Задача организации, в особенности же
реализация намеченных плановых заданий
обеспечивает широкому кругу
(специалистов) участие в формировании
направлений прогрессивного развития.
</div>
<div>
<img src="./cats.png">
</div>div.info { border: 1px solid black; }
.info.red { color: red; }
a[href].red { opacity: .9; }
a.red:hover { color: purple; }
#red#big { opacity: .9 }<html>
<ul>
<li></li>
<li></li>
<li>
<ul>
<li></li>
<li></li>
</ul>
<ul>
<li></li>
</ul>
</li>
</ul>
<p></p>
</html>
<html>
<ul>
<li></li>
<li></li>
<li>
<ul>
<li></li>
<li></li>
</ul>
<ul>
<li></li>
</ul>
</li>
</ul>
<p></p>
</html>
<html>
<ul>
<li></li>
<li></li>
<li>
<ul>
<li></li>
<li></li>
</ul>
<ul>
<li></li>
</ul>
</li>
</ul>
<p></p>
</html>
<html>
<ul>
<li></li>
<li></li>
<li>
<ul>
<li></li>
<li></li>
</ul>
<ul>
<li></li>
</ul>
</li>
</ul>
<p></p>
</html>
<html>
<ul>
<li></li>
<li></li>
<li>
<ul>
<li></li>
<li></li>
</ul>
<ul>
<li></li>
</ul>
</li>
</ul>
<p></p>
</html>
<p class="red yellow">
Красный или желтый
</p>.yellow {
color: yellow;
}
.red {
color: red;
}<p class="red yellow">
Красный или желтый
</p>p.yellow {
color: yellow;
}
.red {
color: red;
}<p id="red" class="yellow">
Красный или желтый
</p>p.yellow {
color: yellow;
}
#red {
color: red;
}Идентификатор
классы
псевдоклассы
атрибуты
элемент
псевдоэлемент
id="example"
#example { }
class="example"
.example { }
div
div { }
универсальный селектор, комбинаторы потомков, детей и прочие не влияют на специфичность
div {
color: blue;
font-weight: bold;
font-size: 12px;
}
div#id {
font-size: 15px;
}
html div {
color: red;
}/* 0 0 1 */
/* 1 0 1 */
/* 0 0 2 */
div {
color: blue;
font-weight: bold;
font-size: 12px;
}
div#id {
font-size: 15px;
}
html div {
color: red;
}/* 0 0 1 */
/* 1 0 1 */
/* 0 0 2 */
/* 0 0 1 */
/* 0 0 1 */
color: blue; /* 0 0 1 */
font-weight: bold; /* 0 0 1 */
font-size: 12px; /* 0 0 1 */
color: red; /* 0 0 2 */
font-size: 15px; /* 1 0 1 */
color: blue; /* 0 0 1 */
font: 13px Arial; /* 0 0 1 */
font-size: 12px; /* 0 0 1 */
font-weight: bold; /* 0 0 1 */
color: red; /* 0 0 2 */
font-size: 15px; /* 1 0 1 */
<div style="color: blue"></div>
div {
color: green !important;
}
<div style="color: white !important"></div>
Инлайн стили по умолчанию приоритетнее стилей в CSS
Стили в CSS с !important приоритетнее инлайн стилей
Инлайн стили с !important приоритетнее всего
(на самом деле нет)
<div>
Привет,
<abbr title="школа">
Школа
</abbr>
</div>
div {
color: green; /* 0 0 1 */
/* abbr { color : green } – нет специфичности */
}
Стили, которые наследуются (Полный список)
color
cursor
direction
empty-cells
font-family
font-size
font-weight
font-style
font-variant
font
word-spacing
letter-spacing
list-style-type
list-style-position
list-style-image
list-style
line-height
quotes
text-align
text-indent
text-transform
visibility
white-space
Абсолютные единицы удобны при определении CSS для печати. В вебе же практически не используются