Klasy HTML

Categorize HTML (set class) so that we can define CSS styles for the class of the element.

Set the same style for the same class, or set different styles for different classes.

Przykład

<!DOCTYPE html>
<html>
<head>
<style>
.cities {
    background-color:black;
    color:white;
    margin:20px;
    padding:20px;
} 
</style>
</head>
<body>
<div class="cities">
<h2>London</h2>
<p>
London is the capital city of England. 
To jest najbardziej zaludnione miasto w Wielkiej Brytanii, 
with a metropolitan area of over 13 million inhabitants.
</p>
</div> 
</body>
</html>

Spróbuj sam

Categorize block-level elements

The HTML <div> element isBlock-level elementsIt can be used as a container for other HTML elements.

Set the class of the <div> element so that we can set the same class for the same <div> elements:

Przykład

<!DOCTYPE html>
<html>
<head>
<style>
.cities {
    background-color:black;
    color:white;
    margin:20px;
    padding:20px;
} 
</style>
</head>
<body>
<div class="cities">
<h2>London</h2>
<p>London is the capital city of England. 
To jest najbardziej zaludnione miasto w Wielkiej Brytanii, 
z obszarem metropolitalnym przekraczającym 13 milionów mieszkańców.</p>
</div>
<div class="cities">
<h2>Paris</h2>
<p>Paris jest stolicą i najbardziej zaludnionym miastem Francji.</p>
</div>
<div class="cities">
<h2>Tokio</h2>
<p>Tokio jest stolicą Japonii, centrum Greater Tokyo Area,</p>
i najbardziej zaludnionym obszarem metropolitalnym na świecie.</p>
</div>
</body>
</html>

Spróbuj sam

Kategorie elementów wewnętrznych

Element <span> HTML jest elementem wewnętrznym, który może być używany jako kontener tekstu.

Ustawienie klasy elementu <span>, pozwala ustawić ten sam styl dla identycznych elementów <span>.

Przykład

<!DOCTYPE html>
<html>
<head>
<style>
  span.red {color:red;}
</style>
</head>
<body>
<h1>Moje <span class="red">Ważne</span> Nagłówek</h1>
</body>
</html>

Spróbuj sam