HTML 类

分类块级元素

HTML <div> 元素是块级元素。它能够用作其他 HTML 元素的容器。

设置 <div> 元素的类,使我们能够为相同的 <div> 元素设置相同的类:

<head>
<style>
.cities {
    background-color:black;
    color:white;
    margin:20px;
    padding:20px;
} 
</style>
</head>

<div class="cities">
<h2>London</h2>
<p>London is the capital city of England. </p>
</div>

分类行内元素

设置 <span> 元素的类,相同的 <span> 元素相同的样式。

<html>
<head>
<style>
  span.red {color:red;}
</style>
</head>
<body>

<h1>My <span class="red">Important</span> Heading</h1>

</body>

有道词典
HTML <sp ...
详细X
HTML < span > element is inline elements, can be used as a text container.
原文地址:https://www.cnblogs.com/azureice/p/8502746.html