CSS styling not displaying in browser (Google Chrome)

Just starting to learn HTML/CSS and working on a project. Struggling because my CSS styles aren't showing up in Chrome when I preview my work. Here's the code I have so far:

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Gritt-ify</title>
    <link rel="stylesheet" type="text/css" href="./resources/css/stylesheet.css">
</head>

<body>
    <!-- Banner section -->
    <div class="banner">
        <h1>Gritty's landing banner</h1>
        <img id="grimage" src ="./resources/images/gritty img.jpg" alt="">
        <p>Cause everything's better with Gritty's face on it</p>
        <button> Subscribe to Gritty</button>  
    </div>

    <!-- Gritter section-->
    <div>
        <span>Gritter</span>
        <p>Social media dedicated to Gritty and only Gritty</p> 
        <form action="">
            <input type="text"/>
            <input type="submit" value="Submit"/>
        </form>
    </div>

    <div>
        <ul>
            <li>
                <div></div><span>Hey there, it's Gritty again.</span>
            </li>
            <li>
                <div></div><span>Hey there, it's Gritty again.</span>
            </li>
            <li>
                <div></div><span>Hey there, it's Gritty again.</span>
            </li>
        </ul>
    </div>
</body>
</html>

Here's the minimal CSS I've added:

.banner {
    background-color: #4D00FF;
    color: white;
    margin-top: 75px;
    text-align: center;
}

#grimage {
    height: 50px;
    width: 50px;
}

If you see an obvious mistake, please let me know. Appreciate any help or suggestions. Thank you.

UPDATE: Issue has been fixed. Thanks to everyone for their input!

Answer №1

To ensure proper functioning, make sure to eliminate the . prefix from your links. This pertains to both your head section and the image in use.

Instead of:

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

Use:

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

Answer №2

Imagine having a single directory dedicated to a specific purpose. Let's call it the "Spiritual Library," where an index.html file and a subfolder named "styles" reside in this manner:

https://i.sstatic.net/SpiritualLibrary.png

Within the styles folder, you'll find the "stylesheet.css" file. The browser must navigate back one level from the current page (index.html) to locate the style sheet inside the styles folder. This means you can reference it as .styles/stylesheet.css

If your structure included a folder called index with the index.html within, then you would require two periods before referencing it like so: ..

An organized file structure looks like this:

~Spiritual Library (parent ~ primary folder)
 -styles (folder) 
       ~ stylesheet.css [file]
 -index.html [file]

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Utilizing Javascript and CSS for horizontal alignment from left to right

I have a JavaScript function that generates a list of store locations and creates a DIV beneath the map. Currently, the items are displayed top to bottom on the page. However, I would like to change the layout so that the items are shown as 3 in a row fro ...

Is it feasible to embed Instagram in an iframe without using the API?

Is there an alternative method to embed Instagram using iframe without the need for an API? ...

Initiate keyframe animation after completion of the transition (CSS)

Can someone assist me with implementing my idea? I want the "anim" animation to start as soon as image1 finishes its transition. My attempted solution: I tried using "animation-delay," but that didn't work for me. The issue is that "animation-delay" ...

What is the best way to include a class with Knockout JS?

After going through the basic Knockout tutorial and examining various examples, I decided to try it out myself on jsFiddle. However, I encountered some issues as my attempts did not quite work. The goal is simple - I just want to add the class open to a d ...

Trigger a click event on a dynamically loaded button

Here's a unique twist to the usual discussions on this topic. I have a dynamically loaded button in my HTML, and I've saved the selector for it. Later on in my code, I need to trigger a click event on this button programmatically. The typical $(& ...

Expanding Iframes in Joomla K2

Sorry if this question has been asked before, but I'm really struggling here... Here is the URL where the issue is happening: I am trying to embed an iframe from one of my client's websites onto my own personal website. Currently, I have the i ...

Tips for using jQuery to dynamically apply CSS styles to new content added to a webpage

I have encountered this question multiple times on stackoverflow and through google search, but unfortunately none of the suggested solutions have worked for me. My issue involves a page that loads an HTML page with empty sections, which are then dynamica ...

A Guide on Modifying a Pseudo Element When Clicked

How can I create a click handler in jQuery to change the color of an 'eyebrow' element above a Heading element? The eyebrow element is set up with a pseudo element in my project, and I'm struggling to make it change color when the heading is ...

Issue encountered while invoking the jQuery html method

Embarking on my first adventure with javascript + jQuery, creating a basic page but running into errors. I've gone through the code multiple times and still can't seem to find the issue. Below is the error message I am encountering: The complet ...

What is the best way to determine the variable height of a div in Angular 7?

I'm currently trying to use console.log in order to determine the height of a div based on the size of a table inside it. This information is crucial for me to be able to ascertain whether or not a scrollbar will be present, especially within a dialog ...

Using images in R Shiny with htmlTemplate: A step-by-step guide

In my current project, I have a file named template.html that I am loading using the code snippet below: https://i.sstatic.net/TipvS.png One issue I'm facing is including an image in this template.html file. Despite having the correct relative path ...

Error: The function getWidget is not defined

I'm encountering an issue while attempting to execute a function in index.php. The error message Uncaught ReferenceError: getWidget is not defined pops up when I try to call the function from widget.php, where it functions correctly. How can I make su ...

A Comprehensive Guide on Creating an Expansive HTML Textbox Covering the Entire

<form method="post" class="mobile-login-form _5spm" id="u_0_0" novalidate="1" data-autoid="autoid_1"> <input type="hidden" name="lsd" value="AVpe_Wp1" autocomplete="off"> <input type="hidden" name="charset_test" value="€,´,€,´, ...

Customizing the width of the JQuery $ui.progressbar by overriding its properties

After spending some time, I successfully overrode the function that controls the width of the progress bar element in the jQuery UI widget version 1.12.1 from September 14, 2016. Initially, I needed the progress bar to completely fill a column in a table. ...

What steps should be taken to incorporate a user input space similar to the one found in the Wordpress new post section

I am looking to incorporate a user input section on my website similar to the one found in WordPress for creating new posts. I would like this area to have all of the same tools available, such as adding hyperlinks, bolding text, and uploading images. Ca ...

Setting up a functionality for a PHP-generated select option

When the main select tag "category" is changed, it triggers a PHP script to display a new select tag: <select id="category" onchange="showme(this);"> <option value="txt">text</option> <option value="img">image</ ...

What are the best methods for efficiently extracting web page content that is nested within HTML pages under the `<body>` tag?

Is there a way to easily extract embedded content like images, PDFs, videos, and documents from HTML web pages without including CSS, CSS background images, or JavaScript? I am in the process of migrating content from an old site to a new site and need to ...

Using select tags in conjunction with JavaScript can add dynamic functionality to your website

I've been working on adding dropdown menus to my website and have been using code similar to this: <select> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="opel">Opel</opti ...

What is the best way to use two distinct CSS styles for mat-form-field across multiple pages?

On one of my pages, I have a mat-form-field: <mat-form-field class="form-control-full-width"> <input type="text" matInput placeholder="First Name" formControlName="firstNameFC" required> <mat-error *ngIf="hasNewUserErro ...

issue with jQuery not properly selecting options based on text

I have three select elements in my code, each containing 3 or 4 options. An "Apply All" button is placed on the first file row. When a user selects a sheet name on the first file and clicks the Apply All button, it should automatically select the same she ...