HTML Code:
<!doctype html>
<html>
<head>
<title>HTML CSS Exercise - calculating values with CSS3</title><!-- Set the title of the HTML page -->
<style type="text/css">
/* CSS styles start here */
.container{
/* Calculate the width */
width: calc(500px - 10%); /* Set the width of the container using the calc() function to subtract 10% from 500px */
background-color:#ec8007; /* Set the background color of the container */
color:#fff; /* Set the text color of the container */
text-align:center; /* Center-align the text within the container */
padding:10px; /* Add padding around the content of the container */
margin: 0 auto; /* Center the container horizontally on the page */
}
/* CSS styles end here */
</style>
</head>
<body>
<div class="container"><!-- Create a container div for content -->
<p>CSS3 <em>calc</em> example</p><!-- Add a paragraph with emphasized text inside the container -->
</div>
</body>
</html>
Explanation:
Live Demo :
See the Pen calculate-values-with-calc()-answer by w3resource (@w3resource) on CodePen.
Supported browser
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4