# Values to set page size in CSS

CSSWeb DevelopmentFront End Technology

#### CSS Online Training

33 Lectures 2.5 hours

#### Kickstart HTML, CSS and PHP: Build a Responsive Website

Featured

59 Lectures 8.5 hours

#### XPath, CSS Selector, Web, DOM, SelectorsHub & TestCase Studio

Best Seller

23 Lectures 8 hours

There are four values that can be used to set page size −

• auto − The page box will be set to the size and orientation of the target sheet.
• landscape − Overrides the target's orientation. The page box is the same size as the target, and the longer sides are horizontal.
• portrait − Overrides the target's orientation. The page box is the same size as the target, and the shorter sides are horizontal.
• length − Length values for the 'size' property create an absolute page box. If only one length value is specified, it sets both the width and height of the page box. Percentage values are not allowed for the 'size' property.

In the following example, the outer edges of the page box will align with the target. The percentage value of the 'margin' property is relative to the target size so if the target sheet dimensions are 21.0cm × 29.7cm (i.e., A4), the margins are 2.10cm and 2.97cm.

<style type = "text/css">
<!--
@page {
size: auto; /* auto is the initial value */
margin: 10%;
}
-->
</style>
Updated on 16-Mar-2020 08:14:58