- Mastering CSS
- Rich Finelli
- 294字
- 2021-07-08 09:45:45
Dissecting a rule set
Let's jump into a CSS file and look at one of the rule sets in the following code block. It's targeting an h2-a level two headline. It's setting a font-size of 26px, a font-style of italic, a color to a shade of red, and a margin-bottom of 10px:
h2 { font-size: 26px; font-style: italic; color: #eb2428; margin-bottom: 10px; }
So nothing too scary here! Let's dissect this a little bit though:
selector { property: value;
property: value;
property: value; }
In the preceding code, h2 is the selector. We are selecting an element on the page to target our style rules. The h2 selector could be a p, an li, a div, an a, or any HTML element we want to target. It can also be a class, an ID, or an element attribute, which I'll talk about later. Next, we have properties and values inside the curly braces. From the opening curly brace to the closing curly brace is the declaration block. You can have as many properties as you want inside the curly braces, or declaration block. font-size, color, font-style, and margin are just a few of the many different properties that you can use. Each property has a corresponding value. Between each property and value, you must have a colon. Following the value is a semi colon, which is also mandatory. Each property and value is called a declaration. So the declaration block is everything inside the curly braces and a declaration is a single line that includes a property and a value. But really, there are three important things to remember in the anatomy of a rule set: the selector, the property, and the value. Now let's look at where we can write these rule sets.
- Learning Neo4j
- Deploying Node.js
- Visual C++程序設計學習筆記
- Kali Linux Web Penetration Testing Cookbook
- Java面向對象軟件開發
- PHP程序設計(慕課版)
- Software Testing using Visual Studio 2012
- Essential Angular
- AIRIOT物聯網平臺開發框架應用與實戰
- Learning Concurrency in Kotlin
- 劍指大數據:企業級數據倉庫項目實戰(在線教育版)
- Python機器學習:預測分析核心算法
- 用戶體驗可視化指南
- Java編程從入門到精通
- Practical Microservices