Write CSS to create a box with border, padding and rounded corners
Description: Create a box that has a 2px green border, 20px padding, 10px rounded corners and a light green background.
Hint:
- Use
border,padding,border-radiusandbackground-color.
CSS for a box with rounded corners
<style>
.box {
width: 300px;
padding: 20px;
border: 2px solid green;
border-radius: 10px;
background-color: #e8f5e9;
}
</style>
<div class="box">This is a box with rounded corners.</div>
Output in the browser:
Output in the browser
This is a box with rounded corners.
How it works
paddingadds space inside the border.border-radiusrounds the corners.
Read CSS Borders and CSS Box Model.
Learn more about the similar topics:
| Tutorials |
|---|
| No Content Found. |
| Exercises & Assignments |
|---|
| No Content Found. |
| Interview Questions & Answers |
|---|
| No Content Found. |