Chapter 12 Flashcards
(92 cards)
CSS-wide keywords (general)
All CSS properties accept the three CSS-wide keywords: initial, inherit, and unset. Because they are shared by all properties, they are not listed with the values for individual property listings.
CSS-wide keywords (initial)
Explicitly sets the property to its default (initial) value.
CSS-wide keywords (inherit)
Allows you to explicitly force an element to inherit a style property from its parent. This may come in handy to override other styles applied to that element and to guarantee that the element always matches its parent.
CSS-wide keywords (unset)
Erases declared values occurring earlier in the cascade, setting the property to either inherit or initial, depending on whether it inherits or not.
Font-family (properties)
Use the font-family property to specify a font or list of fonts.
Values: one or more font or generic font family names, separated by commas
Default: depends on the browser
Applies to: all elements
Inherits: yes
Font-family syntax requirements
All font names, with the exception of generic font families, must be capitalized.
For example, use Arial instead of arial.
Use commas to separate multiple font names. Notice that font names that contain a character space must appear within quotation marks.
Font limitations (fallback)
If the browser can’t find your first choice of font (for example, if that font is not installed on the user’s computer or the provided web font fails to load), the browser uses its default font instead. To avoid this, CSS allows us to provide a list of back-up fonts should our first choice not be available. If the first specified font is not found, the browser tries the next one, and down through the list until it finds one that works. A generic font is applied at a last attempt.
The 5 Generic font family catagories
Serif, Sans Serif, Monospace, Cursive, and Fantasy are the 5 stylistic categories.
Generic font-family: Serif
Serif typefaces have decorative slab-like appendages (serifs) on the ends
of certain letter strokes.
Generic font-family: Sans-serif
Sans-serif typefaces have straight letter strokes that do not end in serifs.
Generic font-family: Monospace
In monospace (also called constant width) typefaces, all characters take up the same amount of space on a line.
Generic font-family: Cursive
Cursive fonts emulate a script or handwritten appearance.
Generic font-family: Fantasy
Fantasy fonts are purely decorative and would be appropriate for headlines and other display types.
Best practice for specifying fonts for web pages (fallback)
Start with your first choice, provide some similar alternatives, and then end with a generic font family that at least gets users in the right stylistic ballpark. A good font stack should include stylistically related fonts that are known to be installed on most computers.
Font-size (properties)
Values: length unit | percentage | xx-small | x-small | small | medium | large |
x-large | xx-large | smaller | larger
Default: medium
Applies to: all elements
Inherits: yes
Can specify size (in font-size) using… (4)
- CSS length units (em).
- Percents.
- Absolute keywords (xx-small, x-small, small, medium/default, large, x-large, xx-large).
- Relative keyword (larger or smaller) in relation to surrounding text.
Preferred sizing values (and non-preferred)
Preferred are em, rem, %. Can use px, but do not provide flexibility required. Unless creating for print, all other absolute units are out.
To maintain the browser’s default size…
Set the font-size of the root element to 100%. It is also common practice to set the body to 100%, but setting it on the html element is a more flexible approach.
Rem values
The rem unit, which stands for “root em,” is always relative to the size of the root (html) element. Because relative to the same element, they are the same size in the document and work like absolute. But, will resize proportionally if root is resized. Best of both worlds.
Em values
Em units are based on the font size of the current element. It will be relative to the inherited size for that element. Once the em is calculated for an element, it can be used for other measurements as that you want to always be relative to the size of the font.
Em values warning
Inconsistency, rounding errors on some platforms/browsers. Also, they are based on the inherited size of the element, which means that their size is based on the context in which they are applied. If you have elements nested several layers deep, the size increase or decrease compounds, which can create problems.
Percentage values (font-size)
Works by creating a size as a percentage of the specified default size.
To calculate % and em values, use this formula:
target size ÷ size of context = result.
Keywords (font-size)
The keywords do not correspond to particular measurements, but rather are scaled consistently in relation to one another.