TAILIEUCHUNG - The CSS Anthology: 101 Essential Tips, Tricks & Hacks- P3

The CSS Anthology: 101 Essential Tips, Tricks & Hacks- P3:Apart from writing books like this one, I write code. I make my living by building web sites and applications as, I’m sure, many readers of this book do. I use CSS to complete jobs every day, and I know what it’s like to struggle to make CSS work when the project needs to be finished the next morning. | Making a Start with CSS 17 The four selectors above all match the paragraph element in the example HTML and set the text color. What color will be applied to the paragraph If you guessed FF0000 or red you d be right. The selectors p any p element and .message any element with class message have the same amount of specificity the selector any p element with class message has a higher level of specificity but the selector content any p element with class message that is a child of the element with id content has the highest. However longer selectors are not necessarily more specific. An ID selector for example will always have a higher specificity than an element type or class selector. It becomes trickier the more complex your selectors are but you should find the examples in this book simple enough. If you d like to know the exact formula for measuring specificity the SitePoint CSS Reference3 has all the answers. If after all of the above have been taken into account two or more style rules are still applicable to an element then the order in which the rules appear the source order is used the last rule to be declared is applied. In the above example the selectors p and .message have the same specificity so in the absence of any other applicable rules the last one declared is used the rule with the selector .message. This is also true if you declare more than one style rule with the same selector .message for example in your style sheet it ll be the second instance of that rule that will be applied to the element. As we ll see in later chapters this behavior is very useful. Summary This chapter has given you a taste of CSS and its usage at the most basic level. We ve even touched on the sometimes difficult concept of the cascade. If you re a newbie to CSS but have an understanding of the concepts discussed in this chapter you should be able to start using the examples in this book. The examples in the early chapters are simpler than those found

TÀI LIỆU MỚI ĐĂNG
4    4    0    15-08-2020
10    5    0    15-08-2020
1    10    0    15-08-2020
21    2    0    15-08-2020
3    2    0    15-08-2020
TÀI LIỆU XEM NHIỀU
TÀI LIỆU HOT
5    4    0
34    3    0
6    4    0
TÀI LIỆU LIÊN QUAN
6    7    0