官术网_书友最值得收藏!

Classifying multiple elements

Classes are also used for classifying multiple elements. If you want to change the h2 tags in the middle section to all be similar but different to h2 tags elsewhere on the page, using a class will be the perfect option. Let's go into our HTML, add a class to all the div tags in the secondary-section, and call it column-title. Go to the The Octopus, The Crab, and The Whale headings, and use Sublime's nice multiple cursor browser feature to add class="column-title" to each one of them. For example, the The Octopus heading should look like this:

<h2 class="column-title">The Octopus</h2> 

Then, we go to our CSS and add .column-title underneath h2. We'll then add some properties and values. Add font-style as normal; you want to get rid of italic. Our color is blue, #0072ae, and we'll make font-weight bold:

.column-title { 
  font-style: normal; 
  color: #0072ae; 
  font-weight: bold; 
} 

Save this, go to the browser, and you'll see that now the h2 tags underneath each image are different to the other h2 tags that you have elsewhere on the site:

The h2 tags at the bottom and the top of the site are still red and in italic:

Classes can be very useful for naming and classifying groups of the same element that you want to look the same. Next, let's rename an element using an ID.

主站蜘蛛池模板: 清涧县| 德令哈市| 沙洋县| 涞水县| 安阳市| 泗水县| 宜川县| 广西| 广宁县| 长治市| 桐梓县| 堆龙德庆县| 三穗县| 克什克腾旗| 邓州市| 霸州市| 大洼县| 潍坊市| 高清| 太仓市| 定南县| 涪陵区| 平凉市| 高要市| 上虞市| 万源市| 雷州市| 松桃| 房产| 嘉荫县| 油尖旺区| 周至县| 英山县| 镇江市| 吉木萨尔县| 恭城| 临江市| 夏邑县| 华容县| 绥化市| 潍坊市|