I can't find out what is wrong with my background - html

So I want to set the file wallpaper.png as the backgound of the page, the image is in the same folder with the html and css files.
<!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="stylesheethome" href="stylesheethome.css"/>
<title>Prism</title>
</head>
<body>
</body>
</html>
And the css:
body {
background-image: url("wallpaper.png");
}

the problemi is with this-
rel="stylesheethome
change it to--
stylesheet... hope this works..
After changing it is working I tried it.

Your body is empty, that's the same for zero pixel height. You can try like this:
html, body {
height: 100%;
}
Good luck.

Try to set stylesheet for rel in your <link> and check your file names.
<link type="text/css" rel="stylesheet" href="stylesheethome.css" />

Try this. I changed the rel attribute value from stylesheethome to stylesheet.
<!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="stylesheet" href="stylesheethome.css"/>
<title>Prism</title>
</head>
<body>
</body>
</html>
stylesheethome is not a valid rel attribute value.
Hope this helps.

Related

Brackets won't let me change the background colour of even a blank document using external CSS

I have been using Brackets for a school image and was trying to move div tags next to each other but was experiencing no change in visuals of the code and I wanted to check if there is an issue with the external CSS so I tried to change the background colour to no successes and haven't even been able to change the background colour of a properly set up blank document.
I have been using the following to try to change the colour.
body {
background-color: green;
}
And this is the blank html for the purpose of testing
<!DOCTYPE html>
<html>
<head>
<title>Solitare</title>
<link rel="stylesheet" href="Untitled-2.css" type="tex/css">
</head>
<body>
</body>
</html>
Am I missing something blindingly obvious or is there another issue?
Thank you very much. G. Ward
probably you have a mistake at <link rel="stylesheet" href="Untitled-2.css" type="tex/css"> try this <link rel="stylesheet" href="Untitled-2.css" type="text/css">
body {
background-color: green;
}
<!DOCTYPE html>
<html>
<head>
<title>Solitare</title>
<link rel="stylesheet" href="Untitled-2.css" type="text/css">
</head>
<body>
</body>
</html>
Your code is just fine!
you are only missing 1 thing a 'text' instead of 'tex'
<link rel="stylesheet" href="Untitled-2.css" type="tex/css"
should be
<link rel="stylesheet" href="Untitled-2.css" type="text/css"

Linking css and html files

I am at my wit's end trying to link my CSS stylesheet to my HTML file, any and all help would be greatly appreciated!
they are in the same folder
my ide of choice is notepad++ (if that makes a difference)
the naming of each file is correct
I have tried multiple browsers
my code is as follows:
<!DOCTYPE html>
<html>
<head>
<title>Christian Potts' Virtual Resume</title>
<style>
<link rel = "stylesheet"
type = "text/css"
href = "style.css" />
</style>
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
stylesheet:
/* style.css */
h1 {
color: Blue;
}
Remove the <style> tags around your <link> tag.
The <style> tag is used to define style information for an HTML document as known as CSS.
Inside the <style> element you specify how HTML elements should render in a browser by writing CSS.
In a <style> your write pure CSS. You can't link your stylesheet inside a <style> tag.
You should end up with this:
<!DOCTYPE html>
<html>
<head>
<title>Christian Potts' Virtual Resume</title>
<link rel="stylesheet"
type="text/css"
href="style.css" />
</head>
<body>
<h1>Hello World</h1>
</body>
</html>
Remove <style> tag which is wrapped around <link> tag.
Your tag should be in the head tag, not the style tag
So it would be as followed:
<!DOCTYPE html>
<html>
<head>
<title>Christian Potts' Virtual Resume</title>
<link rel = "stylesheet" type = "text/css" href = "style.css" />
</head>
<body>
<h1>Hello World</h1>
</body>
</html>

background not setting up

Hello I am trying to set an image as a background using a css file in an index.html, however I use the css declaration the image will not be displayed even if you put it on html, can you please help me figure it out, thank you
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<title>Solution</title>
<style>
body{
background: url("img/notarde.png")
}
</style>
</head>
<body>
HI
</body>
</html>
CssFile
body{
background: url("img/notarde.png")
}
If you have your style in <style></style> it is not needed to add the same content in a CSS file to do it.
However, if you wants to use an external CSS file you can add this line between the <head></head> :
<link rel="stylesheet" type="text/css" href="THE_PATH_OF_YOUR_FILE">
Your code works, it must be the path of the image that went wrong.
See it here
You need to include the stylesheet in the index.html file.
<link rel="stylesheet" type="text/css" href="[your css file path]">
I hope that helps :D
Have you referenced the CSS file in your HTML Page?
<link rel="stylesheet" type="text/css" href="mystyle.css">
Specify the CSS file name and path in href like href="CSS/filename.css"
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<title>Solution</title>
<link rel="stylesheet" type="text/css" href="mystyle.css">
</head>
<body>
HI
</body>
</html>

I can't use CSS code in HTML doc?

I am super new to HTML and CSS and I ran into a problem when I try to link CSS code in HTML. The code doesn't show the background color like it should. HTML Code:
<!doctype html>
<html>
<body>
<link href="styles/main.css" rel="stylesheet" type="text/css"/>
<body>
</html>
CSS code:
body {
background: #999;
}
I have them both in the same folder. I am lost and confused so any help would be greatly appreciated!
CSS files should be included in the head section. If you have them in the same folder you need to change the href aswell.
<!doctype html>
<html>
<head>
<link href="main.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<body>
</html>
You have to use href="main.css"
By using styles/ the browser searches for a folder called styles in the same folders and can't find it so no CSS will be applied
Try adding the link element to head tag instead of body tag.

Linking HTML to CSS

Ok im trying to link my index.html to mystylesheet.css but is isn't working? It works perfectly on CodeAcademy but doesnt seem to work when I run it in chrome. I'm using Notepad++ by the way. When I say isn't working, i mean that the styles in the css aren't coming up, like the background colour for example. here it all is, is there anything im doing wrong?
index.html
<!DOCTYPE html>
<html>
<head>
<link type="text/css" rel="mystylesheet" href="mystylesheet.css"/>
<title>A$AP World</title>
</head>
<body>
<p>Please agree with the terms&conditions before entering.</p>
</body>
</html>
mystylesheet.css
body {
background-color: black;
}
p{
color:red;
}
img {
display: block;
height: 100px;
width: 300px;
margin: auto;
}
Your rel attribute should be rel="stylesheet":
<link type="text/css" rel="stylesheet" href="mystylesheet.css"/>
SitePoint explains it nicely:
The rel attribute defines the relationship that the linked resource has to the document from which it’s referenced. In most cases, this resource will simply be "stylesheet", which means, not surprisingly, “the referenced document is a style sheet.”
Change the rel attribute value, to be rel="stylesheet"
Change this line
<link type="text/css" rel="mystylesheet" href="mystylesheet.css"/>
to be
<link type="text/css" rel="stylesheet" href="mystylesheet.css"/>
Try:
<link rel="stylesheet" type="text/css" href="mystylesheet.css">
Try this:
rel="stylesheet"
instead of
rel="mystylesheet"
<link rel="stylesheet" href="mystylesheet.css" />
As you're using an HTML5 doctype, you can also leave off the type declaration.