Page size in HTML/CSS

By default, the size of a page is 8.5 inches by 11 inches (US Letter). You can set the page size using the size property on the @page selector.

For example, to set the page size to A4, you can use the following CSS:

@page {
  size: A4;
}

Alternatively, you can manually specify the dimensions of the page using any measurement unit (e.g. in, cm, mm, px).

@page {
  size: 11in 17in;
}

Lastly, you can change the orientation of the page by appending landscape or portrait to the size property.

@page {
  size: A4 landscape;
}
Changing a page size to A4 landscape

Pre-defined page sizes

Below is a list of all the pre-defined page sizes that you can use in the size property along with their dimensions.

SizeDimensions
A3297mm x 420mm
A4210mm x 297mm
A5148mm x 210mm
B4250mm x 353mm
B5176mm x 250mm
JIS-B4257mm x 364mm
JIS-B5182mm x 257mm
letter8.5in x 11in
legal8.5in x 14in
ledger11in x 17in

Was this page helpful?