Web development
Viewport and Flexible Units
Updated Oct 28, 2026
The viewport meta tag helps mobile browsers use the device width. CSS units such as percent, rem and viewport units can support flexible designs. Choose units according to purpose, and avoid assuming
What you’ll learn
Understand and practise viewport and flexible units.
Explanation
The viewport meta tag helps mobile browsers use the device width. CSS units such as percent, rem and viewport units can support flexible designs. Choose units according to purpose, and avoid assuming every screen has the same pixel width.
Viewport meta ជួយ browser លើទូរស័ព្ទប្រើទទឹងឧបករណ៍។ ឯកតាដូចជា percent និង rem ជួយបង្កើតទំហំបត់បែន។
Example
Add <meta name="viewport" content="width=device-width, initial-scale=1"> in the head.
Practice
Where does the viewport meta tag belong?
Answer and explanation
Show answer / បង្ហាញចម្លើយ
Inside the HTML head.
Quick recap
The viewport meta tag helps mobile browsers use the device width.