A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.w3resource.com/html-css-exercise/calculate-values-with-calc()-answer.php below:

Website Navigation


HTML CSS Exercise: Calculating Values With CSS3 calc()

HTML CSS Exercise: Calculating Values With CSS3 calc()Last update on March 04 2024 06:50:46 (UTC/GMT +8 hours) Solution:

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