You should understand how to use CSS to control a web page's presentation. If you already know CSS reasonably well, review the MDN CSS reference and ensure you know how to use most of it.
If you need to learn CSS from scratch, refer to these resources:
- MDN: Introduction to CSS
- Learn to Code HTML & CSS
- CSS Reference with visual examples
CSS provides numerous ways of specifying dimensions. There is no single "right" way - each has its own purpose:
px
: small border dimensions (e.g. 1-2px) and image sizesem
: use for specifying font size and padding relative to the element's font size- Use with caution: setting padding in
em
may initially seem to make sense, but on a page with sections that are aligned, either vertically or horizontally, if they have different font sizes and padding specified inem
then they will have different padding values, causing a visual mis-alignment of content across sections.
- Use with caution: setting padding in
rem
: use for specifying font size, margin, and padding relative to the whole page. Margin and padding should usually userem
to maintain consistency throughout the page.%
: use for specifying width/height of an element that should adjust relative to its containervh/vw
: use for specifying width/height of an element that should adjust relative to the viewport sizept
(and others not listed): do not use