HTML Responsive - Javatpoint
HTML Responsive - Javatpoint
HTML Responsive
Responsive Web design
Responsive web design is used to make your web page look appropriate, good, and well placedon all devices (desktop, tablet,
smartphone etc.)
Responsive web design uses HTML and CSS to resize, hide, shrink, enlarge, or move the content. It makes the content look
good on any screen.
Responsive Images
Images which can be scaled nicely to fit any browser size are known as responsive images.
Set the CSS width property to 100% to make the image responsive and scale up and down.
Example
<!DOCTYPE html> ⇧
https://www.javatpoint.com/html-responsive 1/5
4/19/2021 HTML Responsive - javatpoint
<html>
<body>
<h2>Responsive Image</h2>
<p>When we set the CSS width property to 100%, it makes the image responsive.
</body>
</html>
Test it Now
Note: A problem with the above method (width: 100%) is that the image can be scaled up to be larger than its original size. So,
it is better to use the max-width property instead.
Example
<!DOCTYPE html>
<html>
<body>
<h2>Responsive Image</h2>
<p>"max-width:100%" makes the image responsive and also ensures that the image
</body>
</html>
Test it Now
Example
<!DOCTYPE html>
<html>
⇧
<meta name="viewport" content="width=device-width, initial-scale=1.0">
https://www.javatpoint.com/html-responsive 2/5
4/19/2021 HTML Responsive - javatpoint
<body>
<p>Resize the browser width and the image will change at 600px and 1500px.</p>
<picture>
<source srcset="flowers.jpg">
</picture>
</body>
</html>
Test it Now
Responsive Text-size
We can make the text size responsive by using the "uv" unit. It means viewport-width. By using this, we can make the text
size to follow the browserwindow screen.
Example
<!DOCTYPE html>
<html>
<body>
<p>Resize the browser window to see how the text size changes.</p>
</body>
</html>
Test it Now
Note: viewport specifies the browser window size. 1vw = 1% of viewport width. Means, if the viewport is 100cm wide, 1vw is
1.0cm.
Media Query
We can also use media query to make responsive websites. Read the details of media query from here: Media Query
← Prev Next →
⇧
https://www.javatpoint.com/html-responsive 3/5
4/19/2021 HTML Responsive - javatpoint
Preparation
Company
Trending Technologies
https://www.javatpoint.com/html-responsive 4/5
4/19/2021 HTML Responsive - javatpoint
B.Tech / MCA
DBMS DS DAA OS
C++ tutorial
C++
https://www.javatpoint.com/html-responsive 5/5