简体   繁体   中英

What is better HTML code for this

What is better HTML code :

case 1 :

<body bgcolor=" #000000" width="100%" height="100%">
</body>

case 2 :

<body>
<img src="black.jpg" width="100%" height="100%"/>
</body>

seems case 1 wins or css is best option Thanks. Sorry guys i have edited my question again.

Its like this :

What is better HTML code :

case 1 :

<body bgcolor="<!--Is there a color combination code for a photograph/any css approach ?? -->" width="100%" height="100%">
</body>

case 2 :

<body>
<img src="your_photo.jpg" width="100%" height="100%"/>
</body>

Well, I am all this doing because image is too large in size and internet speed is very low.I guess twitter also does it when we set themes( not sure )

This is better:

<body>
...
</body>

and in an external CSS style:

body {
    background: #000 url('black.jpg') no-repeat;
}

通常,css是性能的首选(加载CSS的速度比加载图像的速度更快)。

CSS会更快,并且在高流量站点的主机端产生的带宽浪费更少。

you can set background using CSS instead of loading images everytime into your HTML document, it will help in many cases

as you are using css you won't need to load the image everytime you can set an image background to any class while loading the page it won't load each time but it'll load the page and have the image as its background

<body> </body>

and in a CSS file(external) use

        body
       {     
           background-image: xx.jpg;
         }

avoid using the tag for simplicity purpose use external CSS files to classify the CSS codes

and also avoid

this is totally horrendous when you have to style a very complex site, if you go on styling each and every element in the HTML code itself, at a later stage you'll have to start again from scratch!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM