html学习笔记

2018-06-14——HTML类

2018-06-14  本文已影响0人  Ariel_wyy

分类块级元素

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

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

<html>

<head>

        <style>

                .cities{

                        background-color:black;

                        color:white;

                }

        </style>

</head>

<body>

        <div class="cities">////一个类定义的格式可应用于多个

        <h2>London</h2>

         <p>London is the capital city of England. It is the most populous city in the United Kingdom, with a metropolitan area of over 13 million inhabitants.</p>

        </div>

        <div class="cities">////应用于第二个

        ……

</body>

分类行内元素

HTML <span>元素是行内元素,能够用作文本的容器。

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

<html>

<head>

        <style>

                span.red{

                         color:green;

              }

        </style>

</head>

<body>

         <h1>我的<span class="red"> 重要的</span>标题</h1>

</body>

</html>

这里“重要的”会显示为绿色

上一篇 下一篇

猜你喜欢

热点阅读