CSS (каскадные таблицы стилей) - это язык, отвечающий за внешний вид документа, описанного с помощью языка разметки
<table background="images/awesome-background.gif" border="0" width="300" height="446">
<tr>
<td>
</td>
...
</tr>
<tr>
<td collspan="4">
Разнообразный и богатый опыт начало повседневной
работы по формированию позиции требуют от нас анализа направлений
развития. Постоянный рост и сфера активности влечет за собой
процесс внедрения и модернизации систем массового участия.
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
<img
src="images/super-icon.gif"
alt="Super Icon"
title="Super Icon"
>
<p>
Разнообразный и богатый
опыт начало повседневной
работы по формированию
позиции требуют от нас
анализа направлений развития.
Постоянный рост и сфера
активности влечет за собой
процесс внедрения и
модернизации систем
массового участия.
</p>
<div class="marquee red">Бегущая строка</div>
img {
display: inline-block;
margin: 20px auto;
}
p {
font: 12px/14px 'Comic Sans MS', serif;
}
.marquee {
padding-left: -100%;
overflow: hidden;
animation: scroll 5s infinite linear;
}
.red {
color: red;
}
свойство: значение; /* правило */
свойство: значение; /* правило */
селектор { /* блок объявления стилей */
свойство: значение;
}
селектор {
свойство: значение;
свойство: значение;
свойство: значение;
}
селектор,
селектор,
селектор,
селектор {
свойство: значение;
свойство: значение;
свойство: значение;
}
селектор,
селектор,
селектор,
селектор { /* комментарий */
свойство: значение;
свойство: значение;
свойство: значение;
}
@charset "UTF-8";
@charset "iso-8859-15";
@import 'custom.css';
@import url('fineprint.css') print;
@supports (display: flex) {
div {
display: flex;
}
}
div {
font-size: 12px
color: red
}
font-size: 12px color: red;
p {
font-size: 12px;
color: red;
div {
color: blue;
}
p {
font-size: 12px;
color: red;
}
div {
invalid: 12px;
font-size: invalid;
}
invalid: 12px;
font-size: invalid;
invalid {
font-size: 12px;
}
<p style="color: red;">
<style>
p {
color: red;
}
</style>
<head>
</head>
p {
color: red;
}
h1 {
font-size: 34px;
}
nav {
border: 1px solid black;
}
<h1>Очень важный текст</h1>
<nav>
<a href="/">Главная</a>
<a href="/profile">Профиль</a>
</nav>
<img src="/cats.png">
<p>Вот вам яркий пример
современных тенденций - реализация
намеченных плановых заданий является
качественно новой ступенью
модели развития!</p>
.red {
color: red;
}
.title {
font-size: 34px;
}
.info {
border: 1px solid black
}
<h1 class="title">Очень важный текст</h1>
<nav class="nav">
<a href="/" class="red">Главная</a>
<a href="/profile" class="blue">Профиль</a>
</nav>
<img src="/cats.png" class="cats">
<p class="info red">Вот вам яркий пример
современных тенденций - реализация
намеченных плановых заданий является
качественно новой ступенью
модели развития!</p>
#red {
color: red;
}
#title {
font-size: 34px;
}
#info {
border: 1px solid black
}
<h1 id="title">Очень важный текст</h1>
<nav id="nav">
<a href="/" id="red">Главная</a>
<a href="/profile" id="blue">Профиль</a>
</nav>
<img src="/cats.png" id="cats">
<p id="info">Вот вам яркий пример
современных тенденций - реализация
намеченных плановых заданий является
качественно новой ступенью
модели развития!</p>
#red {
color: red;
}
#title {
font-size: 34px;
}
#info {
border: 1px solid black
}
<h1 id="title">Очень важный текст</h1>
<nav id="nav">
<a href="/" id="red">Главная</a>
<a href="/profile" id="blue">Профиль</a>
</nav>
<img src="/cats.png" id="cats">
<p id="info red">Вот вам яркий пример
современных тенденций - реализация
намеченных плановых заданий является
качественно новой ступенью
модели развития!</p>
* {
font-size: 24px;
}
<h1>Очень важный текст</h1>
<nav>
<a href="/">Главная</a>
<a href="/profile">Профиль</a>
</nav>
<img src="/cats.png">
<p>Вот вам яркий пример
современных тенденций - реализация
намеченных плановых заданий является
качественно новой ступенью
модели развития!</p>
[href] {
color: red;
}
<a href="https://yandex.ru">Яндекс</a>
<a>Пустая ссылка</a>
[href="http://yandex.ru"] {
color: red;
}
<a href="https://yandex.ru">Яндекс</a>
<a href="https://google.com">Google</a>
[href^="https://"] {
color: red;
}
<a href="https://yandex.ru">Яндекс</a>
<a href="https://google.com">Google</a>
[href$="yandex.ru"] {
color: red;
}
<a href="https://yandex.ru">Яндекс</a>
<a href="https://yandex.ru/maps">Яндекс.Карты</a>
[href*="yandex.ru"] {
color: red;
}
<a href="https://yandex.ru">Яндекс</a>
<a href="https://yandex.ru/maps">Яндекс.Карты</a>
a:hover { color: green; }
a:visited { color: purple; }
a:focus { color: yellow; }
<a>Ссылочка</a>
input:disabled {
background: pink;
}
input:enabled {
background: yellow;
}
<input type="text" disabled placeholder="Я не активен!">
<input type="text" placeholder="Я активен!">
input:valid {
background: green;
}
input:invalid {
background: red;
}
<input type="text" class="example-input" pattern="^[a-zA-Z]+$">
:first-child
<html>
<ul>
<li></li>
<li></li>
<li>
<ul>
<li></li>
<li></li>
</ul>
<ul>
<li></li>
</ul>
</li>
</ul>
<p></p>
</html>
:last-child
<html>
<ul>
<li></li>
<li></li>
<li>
<ul>
<li></li>
<li></li>
</ul>
<ul>
<li></li>
</ul>
</li>
</ul>
<p></p>
</html>
:only-child
<html>
<ul>
<li></li>
<li></li>
<li>
<ul>
<li></li>
<li></li>
</ul>
<ul>
<li></li>
</ul>
</li>
</ul>
<p></p>
</html>
:nth-child(2n)
<html>
<div>
<span></span>
<em></em>
<div>
<em>
<span></span>
<span></span>
</em>
<em>
<i></i>
</em>
</div>
<span></span>
<div></div>
</div>
<div></div>
</html>
div:nth-of-type(2n)
<html>
<div>
<span></span>
<em></em>
<div>
<em>
<span></span>
<span></span>
</em>
<em>
<i></i>
</em>
</div>
<span></span>
<div></div>
</div>
<div></div>
</html>
li:not(:first-child)
<html>
<ul>
<li></li>
<li></li>
<li>
<ul>
<li></li>
<li></li>
</ul>
<ul>
<li></li>
</ul>
</li>
</ul>
<p></p>
</html>
::first-letter { color: red }
::first-line { color: blue }
::before,
::after {
color: red;
font-weight: bold;
content: '»';
}
::before { content: '«';}
div.info { border: 1px solid black; }
.info.red { color: red; }
a[href].red { opacity: .9; }
a.red:hover { color: purple; }
#red#big { opacity: .9 }
<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:hover.red { color: purple; }
#red#big { opacity: .9 }
<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:hover.red { color: purple; }
#red#big { opacity: .9 }
<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:hover.red { color: purple; }
#red#big { opacity: .9 }
<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:hover.red { color: purple; }
#red#big { opacity: .9 }
<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:hover.red { color: purple; }
#red#big { opacity: .9 }
<a href="/" class="red">На главную</a>
<div class="info">
Вот вам яркий пример
современных тенденций -
реализация намеченных
плановых заданий является
качественно новой ступенью
модели развития!
</div>
<div><img src="./cats.png"></div>
ul li
<html>
<ul>
<li></li>
<li></li>
<li>
<ul>
<li></li>
<li></li>
</ul>
<ul>
<li></li>
</ul>
</li>
</ul>
<p></p>
</html>
li li
<html>
<ul>
<li></li>
<li></li>
<li>
<ul>
<li></li>
<li></li>
</ul>
<ul>
<li></li>
</ul>
</li>
</ul>
<p></p>
</html>
html > *
<html>
<ul>
<li></li>
<li></li>
<li>
<ul>
<li></li>
<li></li>
</ul>
<ul>
<li></li>
</ul>
</li>
</ul>
<p></p>
</html>
li:first-child + li
<html>
<ul>
<li></li>
<li></li>
<li>
<ul>
<li></li>
<li></li>
</ul>
<ul>
<li></li>
</ul>
</li>
</ul>
<p></p>
</html>
li:first-child ~ li
<html>
<ul>
<li></li>
<li></li>
<li>
<ul>
<li></li>
<li></li>
</ul>
<ul>
<li></li>
</ul>
</li>
</ul>
<p></p>
</html>
Красный или желтый
.yellow {
color: yellow;
}
.red {
color: red;
}
Красный или желтый
Красный или желтый
p.yellow {
color: yellow;
}
.red {
color: red;
}
Красный или желтый
Красный или желтый
html .yellow {
color: yellow;
}
.red {
color: red;
}
Красный или желтый
Красный или желтый
html .yellow {
color: yellow;
}
#red {
color: red;
}
Красный или желтый
идентификаторы
классы
псевдоклассы
атрибуты
элемент
псевдоэлемент
0
0
0
div { /* 0 0 1 */
color: blue;
font-weight: bold;
font-size: 12px;
}
div#id { /* 1 0 1 */
font-size: 15px;
}
html div { /* 0 0 2 */
color: red;
}
div { /* 0 0 1 */
color: blue;
font-weight: bold;
font-size: 12px;
}
html div { /* 0 0 2 */
color: red;
}
div#id { /* 1 0 1 */
font-size: 15px;
}
div {
color: blue; /* 0 0 1 */
font-weight: bold; /* 0 0 1 */
font-size: 12px; /* 0 0 1 */
}
html div {
color: red; /* 0 0 2 */
}
div#id {
font-size: 15px; /* 1 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 {
color: green !important;
}
color: blue; /* 0 0 1 */
font-weight: bold; /* 0 0 1 */
font-size: 12px; /* 0 0 1 */
font-size: 15px; /* 0 0 1 */
color: red; /* 0 0 2 */
<div style="color: blue"></div>
color: green !important;
<div style="color: white !important"></div>
p.class /* 0 1 1 */
.class-1.class-2:first-child /* 0 3 0 */
#id#id /* 2 0 0 */
p.class-1.class-2:nth-child(2n)[href]::after /* 0 4 2 */
Привет,
УрФУ
div {
color: green; /* 0 0 1 */
/* abbr { color : green } – нет специфичности */
}
Привет,
УрФУ
* {
color: red; /* 0 0 0 */
}
div {
color: green; /* 0 0 1 */
/* abbr { color : green } – нет специфичности */
}
Стили, которые наследуются (Полный список)
Абсолютные единицы удобны при определении CSS для печати. В вебе же практически не используются