HTML Code:
<!DOCTYPE html><!-- Declaration of HTML5 document type -->
<html>
<head>
<title>How to set the a background-image as default position of a document</title><!-- Title of the HTML document -->
<style type="text/css">/* CSS style start*/
#xyz1 {
border: 8px solid blue; /* Setting border properties for the element with id "xyz1" */
padding: 40px; /* Setting padding properties for the element with id "xyz1" */
background: url(https://www.w3resource.com/images/w3resource-logo.png); /* Setting background image for the element with id "xyz1" */
background-repeat: no-repeat; /* Preventing the background image from repeating */
background-position: initial; /* Setting the background image position to its default value */
}
</style>
<body>
<div id="xyz1"><!-- Division element with id "xyz1" -->
<h2>Background image position</h2><!-- Heading inside the division element -->
<p>The background-origin CSS property determines the background positioning area, that is the position of the origin of an image specified using the background-image CSS property.</p><!-- Paragraph explaining background-origin CSS property -->
</div>
</body>
</html>
Explanation:
Live Demo:
See the Pen background-position-default-answer by w3resource (@w3resource) on CodePen.
See the solution in the browser
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