Nesting site: how to html to make the background picture

protection click fraud

Many new layout, just get to the heart of creating sites, often wonder how to html to make the background picture.And if some of them can deal with this problem, you still have problems during the stretch the entire width of the image on the monitor.At the same time I would like to see the site are displayed on all browsers, so it must comply with the requirements krossbrauzernosti.You can set a background in two ways: by using HTML tags and CSS styles.Each for himself selects the best option.Of course, CSS style is much more convenient, because the code is stored in a separate file and does not take up extra speakers in the main site tags, but first consider a simple method of setting the background image on the site.

basic HTML tags to create the background

So, go to the question of how to make a background image to html on the screen.In order to look beautiful site, you need to understand a rather important detail: it is enough just to make a gradient background or a solid color to paint it, but if you want to insert the image into the background, it will not stretch the full width of the monitor.The image was originally necessary to pick up or make your own design with this extension, in which you will display the page.Only when the background image is ready, move it to a folder called «Images».In it, we will store all the used images, animations, and other image files.This folder should be in the root directory of the file with all of your html.Now you can move on to the code.There are several options for recording code by which the pattern will change picture.

  1. Write attribute tag.
  2. via CSS style in the HTML code.
  3. Write CSS style in a separate file.

How to HTML to make the background picture, for you to decide, but I would like to say a few words about how it would be the most optimal.The first method is by writing through a tag has long been obsolete.The second option is used very rarely, because it turns out that a lot of the same code.A third option is the most common and effective.Here's the HTML tag examples:

  1. first method of recording through a tag (body) in the file index.htm.It is written in this form: (body background = "Nazvanie_papki / Nazvanie_kartinki.rasshirenie") (/ body).That is, if we have a picture with the name «Picture» and extension JPG, and the folder we named «Images», then the record of HTML-code would look like this: (body background = "Images / Picture.jpg") ... (/ body).
  2. second method involves recording CSS styling, but is written in the same file with the name index.htm.(body style = "background: url ('../ Images / Picture.jpg')").
  3. And the third method of recording is made in two files.The document with the name index.htm tag (head) is written such a line: (head) (link rel = "stylesheet" type = "text / css" href = "Put_k CSS_faylu") (/ head).A style file named style.css already write: body {background: url (Images / Picture.jpg ')}.

How to HTML to make the background picture, we discussed.Now you need to figure out how to stretch the image across the width of the entire screen.

methods of stretching the wallpaper on the width of the window

imagine our screen in percentage form.It turns out that the entire length and width of the screen will be 100% x 100%.We need to stretch the image to this width.Add to record images in the style.css file line that will stretch the image to the entire width and length of the monitor.As it is written in your CSS style?It's simple!

body

{

background: url (Images / Picture.jpg ')

background-size: 100%;/ * This post is suitable for most modern browsers * /

}

So we figured out how to make the picture background to html on the screen.There is a method of recording in the file index.htm.Though this method and outdated, but for beginners it is necessary to know and understand.The tag (head) (style) div {background-size: cover;} (/ Style) (/ head), this record means that we allocate a special unit for the background, which will be positioned over the entire width of the window.We have considered two ways to make the site background picture html, image is stretched to the full width of the screen in any of the modern browsers.

How to make a fixed background

If you decide to use the picture as a background the future of the web resource, then you just need to know how to make it fixed, so that it does not stretch in length and did not spoil the aesthetic appearance.Simply by using HTML code to register a small addition.You need to style.css file to add one sentence after the background: url (Images / Picture.jpg ') fixed;or instead added after the semicolon separate line - position: fixed.Thus, your wallpaper will be fixed.During scrolling a content site, you'll see that the text lines are moving, but the background remains in place.So you learned how to html to make the background image, in several ways.

work with tables in HTML

Many inexperienced web developers, faced with tables and units often do not understand how to html to make the table background image.Like all teams HTML and CSS styles, the language of web programming is quite simple.And the solution to this problem is to write a couple of lines of code.You should already know that writing a table of rows and columns, respectively, as indicated by the tags (tr) and (td).To make the background of the table in the form of images, it is necessary to add to the tag (table), (tr) or (td) a simple phrase with reference to the image: background = URL of the picture.For clarity, we give a couple of examples.

tables with image background instead: HTML examples

Draw a 2x3 table and make it the background image stored in the folder "Images": (table background = "Images / Picture.jpg") (tr) (td)1 (/ td) (td) 2 (/ td) (td) 3) (/ td) (/ tr) (tr) (td) 4 (/ td) (td) 5 (/ td) (td) 6 (/ td) (/ tr) (/ table).So our table will be drawn in the background of the picture.

Now draw the same plate sizes 2x3, but insert a picture in a column number 1, 4, 5 and 6. (table) (tr) (td background = "Images / Picture.jpg") 1 (/ td)(td) 2 (/ td) (td) 3 (/ td) (/ tr) (tr) (td background = "Images / Picture.jpg") 4 (/ td) (td background = "Images / Picture.jpg") 5 (/ td) (td background =" Images / Picture.jpg ") 6 (/ td) (/ tr) (/ table).After watching can see that the background appears only in those cells, in which we have registered, but not the entire table.

Cross-browser site

There is such a thing as cross-browser compatibility web resource.This means that the pages of the site will be equally well displayed in different types and versions of browsers.It should be HTML Code and CSS to customize the style required by browsers.Moreover, in the modern era of smart phones, many web developers are trying to create sites that are adapted and a mobile version of a computer and look.