Wandelblum Wandelblum - 1 year ago 47
HTML Question

I can't get my CSS code to work properly

this is my first post. Despite all efforts, I seem to be a total noob, clearly missing something very simple. I can't get my CSS code to work properly. Here is how:

This is my simple HTML code: (something.html in this example)

<!doctype html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="something.css">
<title>yolo</title>
</head>
<body text="black" background="83467_0003b.jpg">
<h1><center><font face="Arial">Hello World.</font></center></h1>
<a href="something.html"><center><b>Click here</b></center></a>
</body>
</html>


And this is my CSS code: (something.css in this example)

<!doctype html>
<html>
<head>
<style>
body {
background-image: url("83467_0003b.jpg");
background-repeat: no-repeat;
}
a {
color: yellow;
background-color: white;
}
</style>
</head>
<body>

</body>


*Now, I can't get the background image to stop repeating itself;

*I can only use the plain "a" to give new attributes to the link (only color, background color doesn't work). If I use "a: link" the link goes back to its default attributes.

What should I do?


  • U P D A T E * The problem is solved. I accidentally put html tags in the css code X( Thanks for pointing it out!


Answer Source

remove the style from body otherwise the tag style override the css in external file

<!doctype html> 
<html>
  <head>
    <link rel="stylesheet" type="text/css" href="something.css">
    <title>yolo</title>
  </head>
  <body >
    <h1><center><font face="Arial">Hello World.</font></center></h1>
    <a href="something.html"><center><b>Click here</b></center></a> 
  </body>

In .css file use only css statement no HTML o javascript code

something.css

body {
    background-image: url("83467_0003b.jpg");
    background-repeat: no-repeat;
}
a {
    color: yellow;
    background-color: white;
}