Intro to Design Layouts
Learn how spacing, alignment and sizing shape a layout, and how fixed and fluid layouts adapt to screens.
Layout is how elements are sized, spaced and positioned on a screen. This lesson covers the basic building blocks, such as spacing, margins, padding, keylines and alignment, and how fixed and fluid layouts behave as screens change size.
Spacing

Spacing is the set of distances between and inside elements. In the example, the crowded cards touch each other, while the balanced cards have an even gap between them.
Consistent spacing makes a layout feel organized and shows which elements belong together. Most teams pick a small set of spacing values and reuse them everywhere.
Spacing works at two levels:
- Layout spacing: the larger gaps between major regions, such as a header, sidebar and content.
- Component spacing: the smaller gaps inside a component, such as between a button’s icon and label.
Margins

A margin is the space outside an element. In the example, the orange area marks the margin that separates the two cards.
Margins create breathing room. They keep elements from crowding each other and help people see where one item ends and the next begins.
Margins also appear at the edges of the screen, keeping content away from the very edge of a window or device.
Padding

Padding is the space inside an element, between its edge and its content. In the example, the arrows show the space between the edges of the Continue button and its label.
Padding keeps content from touching the edges, which makes it easier to read. When padding is part of an interactive button, it also enlarges the area people can tap or click.
The difference: margin is space outside an element’s border. Padding is space between the content and the border.
Keylines

Keylines are invisible guide lines that keep elements lined up. In the example, two orange keylines run through all three rows.
Every icon sits between the same two lines, and every label starts right after them. The rows line up even though their text is different.
Keylines are often used for things the main grid does not cover, such as icons, avatars and text in a list. They do not appear in the final design.
Left alignment

Left alignment lines elements up along a shared left edge, as the bars in the example show.
In languages that read left to right, every line starts in the same place, so the eye can easily find the start of the next one. That makes left alignment the best choice for most body text.
In right-to-left languages such as Arabic and Hebrew, the same idea applies to the right edge.
Right alignment

Right alignment lines elements up along a shared right edge, as in the example.
For long text in left-to-right languages, it is hard to read, because every line starts in a different place.
It works well for whole numbers in tables, where a shared right edge lines up the last digits so values are easy to compare. When values have different numbers of decimal places, align them on the decimal point instead, so the place values line up.
Center alignment

Center alignment places elements around a shared center line, as the bars in the example show.
It creates a balanced, formal look and suits short content such as headings, button labels, empty states and short marketing messages.
Avoid it for long text. When every line starts in a different place, reading more than a few lines becomes tiring.
Top alignment

Top alignment lines elements up along a shared top edge. In the example, three blocks of different heights all start at the same line.
It gives the eye a consistent starting point, which helps when items in a row have different amounts of content.
Product cards, columns of text and navigation items often use top alignment, so their titles line up even when the content below is longer or shorter.
Bottom alignment

Bottom alignment lines elements up along a shared bottom edge. In the example, three blocks of different heights all sit on the same baseline.
This creates a grounded look, like objects standing on a shelf. Bar charts use it, so the heights of the bars are easy to compare.
It is also useful for keeping buttons in a row of cards at the same level, even when the cards hold different amounts of text.
Dimensions

Dimensions are the size of an element. Screens are flat, so interface elements have two dimensions: width and height, as the example shows.
Defining sizes in advance keeps a design consistent. Buttons, icons, avatars and inputs usually come in a few set sizes.
Sizes are measured in units such as pixels (px) on the web, points (pt) on iOS and density-independent pixels (dp) on Android.
Aspect ratio

Aspect ratio is the relationship between an element’s width and height. The example shows the same photo in 1:1, 4:3 and 16:9 frames.
A 1:1 frame is square and common for profile pictures. 4:3 is close to a classic photo, and 16:9 is the wide format of most videos.
Setting a fixed ratio for images keeps grids tidy when people upload photos of different shapes. Crop images to fit the frame instead of stretching them.
Fixed layouts

A fixed layout uses set widths that do not change with the screen. In the example, the content keeps the same width in the narrow window, so the third card is cut off.
Fixed layouts are simple to build and predictable. They suit controlled screens, such as kiosks and digital signs, where the size never changes.
On other devices, they cause problems:
- On small screens, people may have to scroll sideways.
- On large screens, wide empty areas can appear at the sides.
Fluid layouts

A fluid layout stretches and shrinks with the screen. In the example, the same three blocks fill both the wide and the narrow window, getting narrower as space shrinks.
In this example, the blocks resize to fit. Flexible widths can help prevent horizontal scrolling, but long content or minimum widths can still cause overflow.
Fluid layouts still need limits:
- Set minimum and maximum widths so content never gets too cramped or too stretched.
- Use relative units, such as percentages, instead of fixed pixel widths.
- Use images that scale cleanly, such as SVG for icons and illustrations.