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

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.

主站蜘蛛池模板: 扶绥县| 石泉县| 门头沟区| 莱芜市| 高安市| 天祝| 社旗县| 北碚区| 铜鼓县| 广西| 弥渡县| 贵定县| 望城县| 雅安市| 独山县| 新丰县| 蓝山县| 晋中市| 尚义县| 天台县| 阿图什市| 湾仔区| 福泉市| 开阳县| 梁平县| 荔波县| 五寨县| 临漳县| 正蓝旗| 阿拉善右旗| 绥阳县| 巴林左旗| 安新县| 大渡口区| 靖宇县| 株洲市| 新丰县| 墨江| 宁河县| 江山市| 安徽省|