webmastertoolbag.com

Online tools Web school 在线工具 基础教程 菜鸟教程 编程学习 Web 学校
   ❮   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP HOW TO W3.CSS C C++ C# BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT SWIFT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY AWS CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING HTML & CSS BASH RUST TOOLS

Accessibility Text Size


Why

Some people need larger text in order to perceive letters.


What

Users must be able to change the text size without zooming the entire interface.

This is done in the settings of the operating system or the browser. There are many ways of doing this. In the Chrome browser on desktop, you can set the font size in settings under Appearance and Customize fonts.


How

Let us open the website for LG in India in the Chrome browser on a desktop or laptop computer.

This is what the section Most popular looks like with default browser settings.


Browser settings

Now, in your Chrome browser, set the font size to 40 pixels. That is 2.5 times the default size. For low vision users, this is not much.

.model-name {
  font-size: 18px;
  line-height: 22px;
  height: 66px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}


Relative units

To solve this, let us try rem instead of px. 18 px is 1.125 rem if the base size is 16 px.

.model-name {
  font-size: 1.125rem;
  line-height: 22px;
  height: 66px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

There are several reasons for this. First of all, the line-height is set in pixels. As with font size, we should avoid absolute units when setting line height. line-height can be set with a number without a unit, instead of a length. In this case, we can use line-height: 1.2; instead of line-height: 22px;

The container of the product title has height: 66px; – not a good idea when you want to support text zoom. Let us try to remove that absolute height. 

The last problem is that this product title has -webkit-line-clamp: 3; that limit the text to three lines. Important information is lost.

.model-name {
  font-size: 1.125rem;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
}

Result

Finally, large and readable text. 

This course will not cover all techniques for supporting text resizing. The main takeaways are that you should test the sites you code, and strive to use relative units.  



×

Contact Sales

If you want to use Webmastertoolbag services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com

FORUM ABOUT ACADEMY
Webmastertoolbag is optimized for learning and training. Examples might be simplified to improve reading and learning. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using Webmastertoolbag, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. Webmastertoolbag is Powered by W3.CSS.