once, The background-image is repeated as much as possible without clipping. So, today we are here to show you that how to set background image in html with no-repeat and without CSS. If you need to stretch your background image while resizing the screen and you don't need compatibility with older browser versions this will do the work: body { background-image: url ('../images/image.jpg'); background-repeat: no-repeat; background-size: cover; } Share Improve this answer Follow answered Dec 22, 2016 at 16:48 leocborges To make a background image not repeat in HTML, specify no-repeat in the background-repeat property or the background shorthand property. We hope that you will understand the example properly, we define this in last points also. Also, to make sure the entire element is always covered, set the Some images should be repeated only horizontally or vertically, or they will look strange, like this: If the image above is repeated only horizontally (background-repeat: repeat-x;), the background will look Why is a graviton formulated as an exchange between masses, rather than between mass and spacetime? whitespace is distributed evenly between the images, The background-image is repeated and squished or stretched to fill the Examples might be simplified to improve reading and learning. When was the term directory replaced by folder? DOCTYPE html> which we used as an instruction to the web browser about what version of HTML file is written in. Examples might be simplified to improve reading and learning. You can use it to set both your image location and its repeating property in one place. Asking for help, clarification, or responding to other answers. The first property that is background-image is used to give url of image in body, the other background-repeat is used to not repeat images continuously, after this we use height and width with 100% value, so that it covers full screen or display or browser. In this tutorial we will show you the solution of HTML background image no-repeat without CSS, in HTML sometimes we want to set image as background. We could also specify repeat-x to make it repeat horizontally, repeat-y to make it repeat vertically, or simply repeat to repeat horizontally and vertically. There are many problems like, the image width is greater than browser screen, and the size of image is short and not covers the screen, whereas sometimes the image repeats itself again and again. If no background-position is specified, the image is always placed at the element's top left corner. Examples might be simplified to improve reading and learning. This prevents the image repeating across the element (in the event that the image is smaller than the element). The first property that is background-image is used to give url of image in body, the other background-repeat is used to not repeat images continuously, after this we use height and width with 100% value, so that it covers full screen or display or browser. The first This is default, The background image is only repeated horizontally, The background image is only repeated vertically. It will repeat as many times as necessary until it covers the whole element. From the examples above you have learned that background images can be styled by using the CSS background properties. to no-repeat. Now we'll use the CSS background-repeat property. But we will teach you the one in which the image should no-repeat and it covers full screen. It won't repeat because I've specified no-repeat. property, HTML DOM reference: Can I have multiple background images using CSS? So, both have and ending tags respectively. First, we write which we used as an instruction to the web browser about what version of HTML file is written in. Here, we use style tag in body, which is discussed in next point. width) for another one to be added. In conclusion, here we can say that you are now able to make or set an image in background with no-repeat and full screen also. Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. This class is used to repeat the background image both horizontally and vertically. Browse other questions tagged, Where developers & technologists share private knowledge with coworkers, Reach developers & technologists worldwide. The reason it's repeating, is that you're setting the whole background property. This can be done with or without CSS. The above example uses the background-repeat property to set the image to no-repeat. If the "repeat-x" value is set, the image will be repeated only horizontally. 100% 100%: Try resizing the browser window, and you will see that the image will stretch, but always cover the entire element. If you want to report an error, or if you want to make a suggestion, do not hesitate to send us an e-mail: W3Schools is optimized for learning and training. and last images are pinned to either side of the element, and whitespace /* This will size the image to full width */ body{ background-size: cover; } Edit Example. The last image will be clipped if it does not fit. Secondly, the tag is used to indicate the beginning of an HTML document. While using W3Schools, you agree to have read and accepted our. The background-repeat property gives you control over how your image repeats. But due to some reason we are unable to set image as background accurately. disturb the text too much. The background property is a shorthand property that allows you to set multiple properties at once. Of course, you'll only see this effect if the background image is smaller than its container. This concept not matters, but this matters that how we set image as background in html without any code. TalkersCode is one of the best and biggest website for web developers in India. But due to some reason we are unable to set image properly as background. Now, our task is to give dimensions. As the allowed space increases in size, the repeated images will stretch We want to change the position of the image, so that it does not Thirdly, tag is used to define the webpage body. and the CSS background-image property: Add a background image on a HTML element: You can also specify the background image in the