plain-site › layout

Layout without CSS

The default layout is one column, top to bottom, in source order. That is the right layout for almost every page, and it is already responsive. Everything below is for the few cases where it isn't enough. Reach for it last.


■ The measure table (a max-width without CSS)

The one real cost of zero CSS: on a wide monitor, text runs edge to edge and long lines are hard to read. A plain <table width="640"> fixes the desktop but overflows a phone. This does both: a full-width table with an empty cell either side of a width="640" cell. On a wide window the middle cell is 640px and centred. On a narrow one the empty cells collapse and the text cell shrinks to fit, with no sideways scroll. Drop the first empty cell to align left instead.


※ Measured in Chrome 155: at a 1400px viewport the cell is 640px. At 500px it is 484px and the page has no horizontal scroll. role="presentation" tells screen readers it is not a data table.

■ Alignment: <center> and align

<center> centres text and the blocks inside it, tables included. align on <p>, <div> and headings takes left, right, center, justify. <div align="center"> centres child tables too.


■ Tables: borders, padding, spacing

border (width in px, bevelled), bordercolor (flat, one colour), cellpadding, cellspacing (0 joins the cell borders), width, height, align / valign on cells, nowrap, colspan / rowspan. frame and rules choose which edges get lines.


■ Two columns: the layout table

The 1998 page: navigation on the left, content on the right. Use it sparingly. On a phone the columns stay side by side, so keep the narrow one very narrow, or put it on top instead. valign="top" on the cells, or content floats to the vertical middle.


■ Images beside text: img align

align="left" / "right" floats an image so text wraps round it. hspace / vspace add a gap. <br clear="all"> drops below the image. The other values (top, middle, bottom) line it up inside a line of text.


■ Indentation: lists, blockquote, dl

Every browser indents <blockquote>, <dd>, and lists by 40px. Nesting is the indent system. Lists take type: disc / circle / square on <ul> (obsolete), and 1 a A i I on <ol> (conforming), plus start and reversed.


■ Page margins

The default page margin is 8px. marginwidth / marginheight (Netscape) and leftmargin / topmargin (Internet Explorer) on <body> both still work. Set them to 0 for edge-to-edge header bars.



▲ top ・ plain-site ・ previous: type ・ next: native