--- url: "https://www.w3.org/WAI/WCAG22/Techniques/css/C28" titulek: "C28: Specifying the size of text containers using em units | WAI | W3C" h1: "Technique C28:Specifying the size of text containers using em units" popis: "" jazyk: "en" kanonicka: "" drobecky: [] zdroj: "live" wayback_snapshot: "" stazeno: "2026-09-14 04:44:17" znaku: 3385 slov: 548 kodovani: "utf-8" sha256: "254f40ddf1ddb2aa595110fcfb5abed6529895758b07b93aa83fa33ed8cf1f1a" --- # Technique C28:Specifying the size of text containers using `em` units ## About this Technique This technique relates to: - [1.4.4 Resize Text](https://www.w3.org/WAI/WCAG22/Understanding/resize-text) ( **Sufficient** when combined with other techniques) - [1.4.12 Text Spacing](https://www.w3.org/WAI/WCAG22/Understanding/text-spacing) ( **Advisory** ) This technique applies to CSS. Techniques are examples of ways to meet Web Content Accessibility Guidelines (WCAG). They are **not required** to meet WCAG. Content can satisfy the normative requirements of WCAG even if it does not use any of the documented techniques. See [About WCAG Techniques](https://www.w3.org/WAI/WCAG22/Techniques/about). ## Description The objective of this technique is to specify the width and/or height of containers, that contain text or that will accept text input, in `em` units. This will allow user agents that support text resizing to resize the text containers in line with changes in text size settings. The width and/or height of text containers that have been specified using other units risk text cropping because it falls outside the container boundaries when the text size has been increased. The containers generally control the placement of text within the web page and can include layout elements, structural elements and form controls. Note This technique uses `em` units, but using `rem` units instead would have the same effect. ## Examples ### Example 1: `em` units for sizes for layout container containing text In this example, a `div` element, with `id` value of `"nav_menu"`, is used to position the navigation menu along the left-hand side of the main content area of the web page. The navigation menu consists of a list of text links, with `id` value of `"nav_list"`. The text size for the navigation links and the width of the container are specified in `em` units. ``` #nav_menu { width: 20em; height: 100em; } #nav_list { font-size: 100%; } ``` ### Example 2: `em` units for text-based form controls In this example, `input` elements that contain text or accept text input by the user have been given `class="form1"`. CSS rules are used to define the font size in percent units and width for these elements in `em` units. This will allow the text within the form control to resize in response to changes in text size settings without being cropped (because the width of the form control itself also resizes according to the font size). ``` input.form1 { font-size: 100%; width: 15em; } ``` ### Example 3: `em` units in dropdown boxes In this example, `select` elements have been given `class="pick"`. CSS rules are used to define the font size in percent units and width in em units. This will allow the text within the form control to resize in response to changes in text size settings without being cropped. ``` select.pick { font-size: 100%; width: 10em; } ``` ### Example 4: `em` units for non-text-based form controls In this example, `input` elements that define checkboxes or radio buttons have been given the class name "choose." CSS rules are used to define the width and height for these elements in `em` units. This will allow the form control to resize in response to changes in text size settings. ``` input.choose { width: 1.2em; height: 1.2em; } ``` ## Tests ### Procedure - Identify containers that contain text or allow text input. - Check the container's width and/or height are specified in `em` units. ### Expected Results - Check #2 is true. Back to Top