Semantics, box model, layout, responsive design
Practise these as flashcards. One or two lines each; the ones you miss come back first.
Start freeSemantic HTML uses elements that describe their meaning in the context of the page, like <header>, <main>, or <footer>. It's important because it improves accessibility, SEO, and code clarity.
The box model consists of content, padding, border, and margin. The total size of an element is the sum of these parts, which affects layout and spacing.
I use flexible units like percentages or rem, CSS media queries to adjust styles for different screen sizes, and a mobile-first approach to ensure layouts work well on all devices.
display: flex property do?display: flex turns an element into a flex container, enabling its children to be laid out using the flexbox model, which makes alignment and spacing much easier.
position: absolute and position: relative.position: absolute removes the element from the normal flow and positions it relative to the nearest positioned ancestor. position: relative keeps the element in the flow but allows you to offset it from its normal position.
Specificity is calculated based on the types of selectors used: inline styles, IDs, classes, and element selectors. Higher specificity rules override lower ones, and if specificity is equal, the last rule in the source order wins.
I use CSS Grid for two-dimensional layouts where I need to control both rows and columns, like dashboards. Flexbox is better for one-dimensional layouts, such as navigation bars.
I define variables with --var-name syntax, usually in the :root selector for global scope, and use them with var(--var-name). This helps with theming and keeping styles consistent.
The cascade is the process by which browsers determine which CSS rules apply to an element, resolving conflicts based on specificity, importance, and source order.
I use input types like email or number, and attributes like required, min, max, or pattern. Browsers then handle validation and show error messages automatically.
Mobile-first design means writing styles for small screens first, then using media queries to add enhancements for larger screens. It's recommended because it ensures a good experience on the most constrained devices.
I set explicit width and height attributes on images or use aspect-ratio in CSS, so the browser can allocate space before the image loads, preventing layout shifts.