Hi,
This is my code but I am given an error message:
Please advise.
body {
background-image: https://cdn.freecodecamp.org/curriculum/css-cafe/beans.jpg ;
}
You should set the background-image
property to url(https://cdn.freecodecamp.org/curriculum/css-cafe/beans.jpg)
.
<!-- file: index.html -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Cafe Menu</title>
<link href="styles.css" rel="stylesheet"/>
</head>
<body>
<div class="menu">
<header>
<h1>CAMPER CAFE</h1>
<p>Est. 2020</p>
</header>
<main>
<section>
<h2>Coffee</h2>
</section>
</main>
</div>
</body>
</html>
/* file: styles.css */
section {
background-image: https://cdn.freecodecamp.org/curriculum/css-cafe/beans.jpg;
}
h1, h2, p {
text-align: center;
}
.menu {
width: 80%;
background-color: burlywood;
margin-left: auto;
margin-right: auto;
}
**Your browser information:**
User Agent is: Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36
Challenge: Learn Basic CSS by Building a Cafe Menu - Step 29
Link to the challenge:
This isn’t formatted correctly.
Example of how it’s used:
background-image: url(Enter-your-url-here!);
I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.
You can also use the “preformatted text” tool in the editor (</>
) to add backticks around text.
See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').
Thanks for the quick response!
I have written it according to the format you mention.
What am I mising here
background-image: url(Enter-your-url-here!);
(adding backticks as requested)
body { background-image: https://cdn.freecodecamp.org/curriculum/css-cafe/beans.jpg;
}
Thanks I will add backticks to the code as requested.
Where have I gone wrong with the code
background-image: https://cdn.freecodecamp.org/curriculum/css-cafe/beans.jpg;
}```
You are missing "URL" infront of the url, and the parenthesis at the start and end of the actual link.
As @Rossvold said, The syntax you’re using for the value for your background-image
is not correct.
here’s an article which explains how to use it.
W3Schools offers free online tutorials, references and exercises in all the major languages of the web. Covering popular subjects like HTML, CSS, JavaScript, Python, SQL, Java, and many, many more.
It works now. Thank you very much!
1 Like
Thanks for the feedback. Much appreciated!
system
Closed
March 21, 2023, 9:20pm
10
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.