font: bold 20px sans-serif;
There exist shorthands for many groups of CSS properties and you can find their de-
scriptions in the CSS reference at the end of the book. Although shorthand properties
can come in handy as they save you time and make style sheets more concise and
readable, there are some caveats to keep in mind when using them.
First of all, they set all the proper ties they are designed to set, even those that you do
not specify explicitly. OK, it’s tru e that they set them to default values, which can’t
hurt. Except if you have set those properties to dierent values before—default values
provided by a sh orthand property will override them. For example, if you decla re:
font-style: italic;
font: bold 20px sans-serif;
then your f ont won’t be set to italic. Namely, the font shorthand property sets
font-style as well, whose default setting is no rmal.
The second thing you should be careful a bout is the order of the values of the proper-
ties that a shorthan d property replaces. Generally, shorthand properties do not require
a specific order of the supplied values. If the values are of dierent types, then there
is no d oubt wh ic h is which and the order is really n ot important. But as soon as there
are more values of identical types, their order bec omes important. The order is even
important in certain cases where the values are of dierent types. For example, the
font shor thand p roperty demands that values for the font-size and font-family
properties are supplied second to last and last, respectively. What’s more, they a re
even required or the whole declaration is ignored. A best practice is that, b efore u sin g
a shorthand property, you carefully read what and how does it set and that you always
stick to the same order of values even whe n the order is not important.
3.6 CSS Pixel Unit
Professor: Finally, I would like to say a few words about units, and then I will give
you homework. Because CSS units in general need a little more discussion th an time
allows today, I will just explain what you need to know to complete your homework.
You have learned that f or specifying sizes and dimensions, you use the <length> data
type, which is a <number> imm ediately followed by a length unit. The only unit I
want you to use right n ow is pixel. Historically, the name is derived from the smallest
dot a computer monitor could displa y, which was called a pixel. Today, devices can
display much smaller dots, which c ould not even be visible to the naked eye but only
through a magnifying glass. Nevertheless, pixels survive in the same way as they
appeared in older documents.
While the definition of a pixel is highly context-sen sitive, a CSS pixel (px) could be
defined as the smallest visible length that can be sh arply displayed. What is small, vis-
ible, and sharp depends on the type of device and its normal use. The important thing
is that the pixel always has the same visual appearance , no matter on which device it is
3.6. CSS Pixel Unit 47
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.146.255.127