简体   繁体   中英

Html css not working correctly

For some odd reason when I try styling this html page with a backround in css nothing appears. Any Ideas on how to fix

-Thanks

<html>
<body>
<title>Test</title>
<b><font color="#F91212"><center>Test</center></font></b>
<br><b><center><font color="#FF0000">Have Fun!</font></center></b></br>
<br><b><font color="#FF0000"><center><a href="">Join now for free by clicking here</a>   </center></font></b></br>
<br><center><img src="test.jpg"></img></center></br>
<style>
body {background-color:#b0c4de;}
</style>
</body>
</html>

It should look something like this (notice I moved the style tag within the head tag):

<head>
    <style>
    body{
        background-color:#color;
    }
    </style>
<head>

Why is your style tag in your <body> tag? It should be in the <head> tag:

<html>
    <head>
         <style type="text/css">body { background-color: red; }</style>
    </head>
    <body>
    </body>
</html>

Or even better, put your css in a separate .css file.

First of all that's not how css works or how html works. You should put your style tags in html head section. And you should determine html element where you want to set background-color.

 <html> <head> <style> body { background-color:#b0c4de; } </style> </head> <body> <title>Test</title> <b><font color="#F91212"><center>Test</center></font></b> <br><b><center><font color="#FF0000">Have Fun!</font></center></b></br> <br><b><font color="#FF0000"><center><a href="">Join now for free by clicking here</a> </center></font></b></br> <br><center><img src="test.jpg"></img></center></br> </body> </html> 

Usually the syntax is like so:

<html>
    <head>
    <style>
         body { background: #121212; } 
    </style>
    </head>
</html> 

With the style tag in the head tag.

You will want to move your <style> tag inside of your <head> tag.

Try this code:

CODE

<style>
body {
    background-color:#b0c4de;
}
</style>
<body>
<b><font color="#F91212"><center>Test</center></font></b>
<br><b><center><font color="#FF0000">Have Fun!</font></center></b></br>
<br><b><font color="#FF0000"><center><a href="">Join now for free by clicking here</a>   </center></font></b></br>
<br><center><img src="test.jpg"></img></center></br>
</body>

SAMPLE

http://jsfiddle.net/Uy2Zb/

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