CSS Properties: How to specify that a division element should be resizable by the user
Solution:
HTML Code :
<!DOCTYPE html><!-- Declares the document type and version of HTML -->
<html><!-- Begins the HTML document -->
<head><!-- Contains metadata and links to external resources -->
<title>How to specify that a division element should be resizable by the user</title><!-- Sets the title of the document -->
<style type="text/css"> /* Starts CSS styling */
div { /* Styles all div elements */
border: 2px solid #CC63FF; /* Sets a border for the div elements */
padding: 20px; /* Adds padding inside the div elements */
width: 200px; /* Sets the initial width of the div elements */
resize: both; /* Allows the user to resize both the width and height of the div elements */
overflow: auto; /* Specifies how overflowed content should be handled */
}
</style><!-- Ends CSS styling -->
</head><!-- Ends the head section -->
<body><!-- Begins the body of the document -->
<p>w3resource Tutorial</p><!-- Displays a paragraph with the text "w3resource Tutorial" -->
<div>User resize both the height and the width of the division element.</div><!-- Displays a div element that can be resized by the user -->
</body><!-- Ends the body section -->
</html><!-- Ends the HTML document -->
Explanation:
- The HTML document demonstrates how to specify that a <div> element should be resizable by the user.
- CSS comments are added to explain each section of the code.
- The CSS selector div targets all <div> elements in the document.
- Various CSS properties are applied to the <div> elements to achieve the desired styling and functionality:
- border sets a border around the div elements.
- padding adds spacing inside the div elements.
- width sets the initial width of the div elements.
- resize allows the user to resize both the width and height of the div elements.
- overflow specifies how overflowed content should be handled, with auto allowing scrolling when needed.
Live Demo :
See the Pen resize-answer by w3resource (@w3resource) on CodePen.
See the solution in the browser
Supported browser
Yes | Yes | Yes | Yes | Yes |
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics