0

enter image description hereBelow my code runs fine, but when I preview the html file in browser, none of the styling shows up. When I inspect the element in Chrome dev tools, it shows that it is still trying to just access "style.css" instead of the path I wrote in. I cleared browser cache, I closed and reopened the page, refreshed it, saved the file and closed IDE, etc. What am I doing wrong?

body {
    background: -webkit-linear-gradient(-45deg,#FFFED4,#FFEEFF)

}

h1, p, h3{
    font-family: Arial;
    color: black;


}
h1 {
    font-size: 60px;
    text-align: center;


}

p {
    font-size: 25px;
    text-align: center;

}
img {
    display: block;
    margin-left:auto;
    margin-right: auto;
    width: 50%;

}
h3 {
    font-size: 25px;
    font-family: Helvetica;
    position: relative;
    bottom: 0px;
}
<!DOCTYPE html>
<html>

    <head>
        <title>We Apologize</title>
        <link rel="stylesheet" type="text/css" href="./resources/css/style.css">
        <link rel="icon" type="image/gif/png" href="./resources/img/Brighton-McFarlane13.png">
    </head>

    <body>
        <main>
            <h1>We apologize</h1>
            <p>The site is under construction right now, but we are doing our best to bring it to life! Check back in a few weeks to see the final product!</p>
            <img src="https://i.imgur.com/YjMR0E6.jpg">
        </main>
        <article>
            <p>Soon this site will be a portfolio, shop, and forum for the <a href="https://www.youtube.com/channel/UCLxxUr3dwkzNkIUvFv84k4w/" target="_blank">Brighton McFarlane YouTube Channel!</a></p>
            <img src=./resources/img/Brighton-McFarlane12.png>
            <h3>Thanks for stopping by!</h3>
        </article>
    </body>

<html>

3
  • Check the path to the file. Or check the console for any errors. Commented Jun 9, 2020 at 15:03
  • Upload image of your folders please Commented Jun 9, 2020 at 15:03
  • The hyperlink is my screenshot of the files. Sorry I wasn't sure how images work on here Commented Jun 9, 2020 at 15:10

3 Answers 3

2

sounds like an issue with your relative path. I cannot see how your file directory is set up but try href="resources/css/style.css"

if it still doesn't work you need to move up a folder. href="../resources/css/style.css"

hope this helps!

Sign up to request clarification or add additional context in comments.

4 Comments

<html><head> <link href="style.css" rel="stylesheet" type="text/css"> <link rel="icon" type="image/gif/png" href="Brighton-McFarlane13.png"> <title>We Apologize</title> </head>
Thats how it shows up in Chrome, completely removes my path that I put in.
if its showing without ./resources/css/ then this is not the same file that you are editing vs viewing... double check.
is the page your loading in the same folder as the css file? what does your directory look like?
1

Well turns out I'm an idiot and updated the file path of the html file and Atom didn't automatically update where the file was located, it created some sort of imaginary copy of it. I saved the file to the proper folder and it is working now.

1 Comment

Thank you all for your help!
1

If the resources folder is in the root of your site/folder structure, remove the . before the slash.

<link rel="stylesheet" type="text/css" href="/resources/css/style.css">

What does "./" (dot slash) refer to in terms of an HTML file path location?

/ means the root of the site;

./ means the current directory;

../ means the parent of the current directory.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.