The following are links to additional questions that our community has asked about this exercise:
This list will contain other frequently asked questions that aren’t quite as popular as the ones above.
Currently there have not been enough questions asked and answered about this exercise to populate this FAQ section.
This FAQ is built and maintained by you, the Codecademy community – help yourself and other learners like you by contributing!
Not seeing your question? It may still have been asked before – try searching for it by clicking the spyglass icon () in the top-right of this page. Still can’t find it? Ask it below by hitting the reply button below this post ().
Regarding the background-image selector, does it take precedence over the img tag in html?
Because, when we change the background-image in the css file, it overlay the image from the img in html file.
Please clarify.
Thank you.
The <img> in the HTML file is a completely separate thing to the Background Image which we are replacing in this exercise so, as far as I can see, there are no “precedence issues” or interaction between the two. The <img> in the HTML file is the writer’s avatar, and it remains unaltered at the top of the page with her name.
I’m a beginner too, but I imagine that the <img> is an HTML element because it is not a Background Image, and not in itself part of a CSS styling rule like the url("") is.
However, the <img>is itself styled by the CSS rule set with the .writer-img class selector, and the box-shadow, float, and width properties (right at the bottom of style.css).
I hope that helps … and doesn’t confuse you even more!
When we hover over the image, the foreground is hidden and we see the background image underneath it. I cannot explain the instability (FF) but would suggest this is not a typical approach and obviously should be shyed away from, else solved. A script can likely handle it more stable fashion, though I haven’t tested it that far.
I think I understand what you’re seeing. I didn’t notice that there’s already a background-image property in the .image selector so I added a new one with the link in the instructions, this replaced the old image in the live preview and still counted the task as complete. But it looks like that first soccer image is the one in the original background-image property, and it’s not coming from the HTML code.
Looks like some other folks answered questions regarding HTML and CSS images potentially conflicting but it does appear that adding a second background-image property replaced the one that was used earlier in the same .image selector.
I guess what the lesson wanted though was for us to just replace the URL.
Trying to confirm in my head why you would have images in your CSS rather than in html. Is it because things like background images are best set in CSS rather than HTML? img src tag is so familiar to me now, I’m reluctant to let it go!
If you mean images from someone else’s site this is a frowned upon practice called, hotlinking. It is tantamount to content theft unless you have written permission from the site’s owner. Search Engines are aware of this and may discount the rank of your site. When we control the content, we don’t have to worry about it being removed.
Sites that host images such as Content Distribution Networks generally do not remove content arbitrarily unless their is a non-payment issue.
Bottom line, if it is not our own image, it should not be on our site.
Images are content; background images are window dressing. Anything that has a direct bearing on the article (page topic) deserves to be an image with caption and alternate text. If it is just for visual effect in a page design, then it should be a CSS background.
I am super new to coding and have been really enjoying Codecademy as a starting point.
So, I attempted to create a background image on a website using Visual Studio Code. I used a jpeg file that is saved on my computer. When I did the following in my index.css:
The photo does not appear on the webpage. However, a large space is created on the page where the photo should be.
When I use the same /resources/IMG_7477.jpeg file on the index.html in the following way:
And then place the following in to the index.css for the project:
.YMCA {
width: 25em;
}
The photo appears on the webpage, and I can use the css to style it. However, I want to make this photo a background-image so I can place text on top of it. Can anyone tell me what I am doing wrong?
Where is your CSS relative to the index.html? Trace the path back from there to the image.
Aside
One should avoid using the root of your C drive for your projects. Use your User account Documents folder. Make your file paths relative to the index.html file,and not,
@mtf Thanks for the feedback. As I am very green when it comes to this stuff, I don’t think I fully understand all of your suggestions.
Not sure where my CSS is relative to the index.html. I don’t really understand that question. However, I thought I linked the index.html and index.css together when I did the following in Visual Studio Code:
The index.html and the index.css are both in the main folder “Projects” but each are in different areas of the folder as their are in sub folders:
index.html is in the Projects folder > DevProject folder
index.css is in the Projects folder > DevProject folder > Resources folder > CSS folder
My coding projects are housed in a folder named “Projects” inside of the “Users” folder on my Mac. I found the “Users” folder using the “Finder” on my Mac. Not sure if that means my Projects folder is on the C drive or not.
I am not sure what to do next. But thanks for the help and trying to support newbies like me.
If the css is in a folder inside the resources folder (not how I would do it) then it is two levels down from the index.html, and one level down from the images.
ok, so I followed the directions in the exercise and checked all of my symbols/tags, etc. and it is still telling me I am wrong. I am honestly stumped, and would like another set of eyes to see if I missed something.