Typography Basics and Text-Align
Font family
font-family
determines what font an element uses.
- If a browser cannot find or does not support the first font in a list, it will use the next one, then the next one and so on until it finds a supported and valid font.
font-family: "DejaVu Sans", sans-serif;
- Font family name: like
"DejaVu Sans"
(we use quotes due to the whitespace between words).
- Generic family name: like
sans-serif
(generic family names never use quotes).
Font size
font-size: 22px
Font weight
font-weight
affects the boldness of text, assuming the font supports the specified weight.
font-weight: bold
font-weight: 700 /* (a number between 1 and 1000) */
Font align
text-align: center
Image Height and Width:
img {
height: auto;
width: 500px;
}
- To adjust the size of the image without losing its proportions, you can use “auto” for the
height
property and adjust the width
value.
- It’s best to include both of these properties even if you don’t plan on adjusting the values from the image file’s original ones.
- When these values aren’t included, if an image takes longer to load than the rest of the page contents, the image won’t take up any space on the page at first, but will suddenly cause a drastic shift of the other page contents once it does load in. Explicitly stating a
height
and width
prevents this from happening, as space will be “reserved” on the page and will just appear as a blank space until the image loads.