This margin is due to the fact that all HTML pages are automatically set to have a small margin by default. If you compare the container on your site with the same container on the demonstration site, you may notice that your webpage’s container is surrounded by a small margin of white space. The background image should now be replaced with a container that is the same size but has a solid yellow color. Save the file and reload it in the browser to check your results. To use a background color, replace the element code snippet you just created with the following highlighted element code snippet like this. You should receive something like this:Īlternately, you can use a background color instead of a background image. Save the file and reload it in the browser. Note that you will not be able to see the effects of the padding-top value until we place content inside in the next step. We have also specified the height to 480 pixels and padding-top to 80 pixels, which will create 80 pixels of space between the top of the element and any content we place inside. Comments are used to help explain or organize code to developers. A comment is a piece of code that is ignored by the browser. Note that we have added the comment to help organize our HTML code. Make sure to switch the text that says Image_Location with the file path of your image and don’t forget to add the closing tag. ![]() Next, paste the highlighted code snippet into your index.html file below the opening tag and above the closing tag. Once you’ve chosen your background image, save the image in your images folder as background-image.jpg. ![]() (For a refresher on how to add images to webpages using HTML, please visit our tutorial HTML Images from earlier in this tutorial series). You may download and use our demonstration site’s background image for the purpose of the tutorial, or you can choose a new image. We will use the style attribute to specify the height of our container, apply a background image, and specify that the background image should cover the entire area of the container.īefore we get started, we’ll need a background image. In this tutorial we’ll learn how to use a container to structure the top section of the webpage.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |