How do you make a web page responsive using HTML and CSS?
Do these four things.
- Add the viewport meta tag in the head.
- Make images flexible with
max-width: 100%; height: auto;. - Use relative units like
%andrem, not fixed pixels. - Use media queries to change the layout on small screens.
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
img { max-width: 100%; height: auto; }
.column { width: 50%; float: left; }
@media (max-width: 600px) {
.column { width: 100%; float: none; }
}
</style>
Learn more about the similar topics:
| Tutorials |
|---|
| HTML Semantic Elements |
| HTML Responsive Design |
| Exercises & Assignments |
|---|
| Write an HTML program to create a navigation menu |
| Write an HTML program to create a page layout with semantic elements |