Seemingly correct code failing on test

Seemingly correct code failing on test
0.0 0

#1

I’m on the Applied Visual Design portion doing the challenge called “Create Texture by Adding a Subtle Pattern as a Background Image” and below is my code.

<style>
  body {
    background: url(
      https://i.imgur.com/MJAkxbh.png
    );
</style>

The challenge asks to “Using the url of https://i.imgur.com/MJAkxbh.png, set the background of the whole page with the body selector.” Where have I gone wrong because it won’t allow me to continue forward otherwise.


#2

The url text needs to be inside quotation marks.


#3

so I should be:

<style>
  body {
    background: url(
      "https://i.imgur.com/MJAkxbh.png"
    );
</style>

The error I’m still getting is “Your body element should have a background property set to a url() with the given link.” even though it’s displaying properly when rendered


#4

The test is being a little picky. It is not expecting you to put the actual url string on a separate line. It would best practice to not do that anyway.


#5

url put in quotation


#6

That’s pretty obnoxious. Why is it bad practice to write it this way, for my own sake?


#7

If you have used JavaScript functions before, think of url as a function in JavaScript. Let’s say you had a function named displayURL in JavaScript (see below).

function displayURL(url) {
  console.log(url);
}

You would not call the function displayURL like:

displayURL(
"https://www.freecodecamp.org"
);

Instead, you would call it like:

displayURL("https://www.freecodecamp.org");

This makes it clear the string is an argument to the function.


#8

Oh man that makes a lot of sense. I was thinking of it more like block than an argument. Thank you