What could be causing the background color not to change on the HTML page with Bootstrap?

Learning html, bootstrap, and css styling can be a confusing endeavor. Sometimes things don't work as expected, like changing the background color. Despite following what seems like a simple solution after googling, the background color remains unchanged in the code below. Spending time experimenting with different variations might eventually solve the issue, but the real question is why it doesn't work in this example where the body is explicitly set to have a background color of #000000.

<!doctype html>

<html lang="en">
<head>
    <meta charset="utf-8">

    <title>Portfolio</title>
    <meta name="description" content="Portfolio page">
    <meta name="author" content="Christoffer Berg">

    <link rel="stylesheet" href="css/styles.css?v=1.0">
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

</head>

<body>

    <nav class="navbar navbar-default" role="navigation">

        <div class="navbar-header">
            <a class="navbar-brand" href="#">Portfolio</a>
        </div>

        <div>
            <ul class="nav navbar-nav">
                <li class = "active"><a href="#">Home</a></li>
                <li><a href="#">About</a></li>
                <li><a href="#">Portfolio</a></li>
                <li><a href="#">Contact</a></li>
            </ul>
        </div>
    </nav>

    <div class="container-fluid text-center bgim bgimg">
        <div class="row">
            <div class="col-sm-12">
                <h1>Home</h1>
            </div>
        </div>
    </div>

    <div class="container-fluid text-center bgim bgimg">
        <div class="row">
            <div class="col-sm-12">
                <h1>About</h1>
            </div>
        </div>
    </div>

    <div class="container-fluid text-center bgim bgimg">
        <div class="row">
            <div class="col-sm-12">
                <h1>Portfolio</h1>
            </div>
        </div>
    </div>

    <div class="container-fluid text-center bgim bgimg">
        <div class="row">
            <div class="col-sm-12">
                <h1>Contact</h1>
            </div>
        </div>
    </div>
    <script src="js/scripts.js"></script>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</body>
</html>

The styles.css file:

h1 {
    font-family: "Courier New", Courier, monospace;
}

body {
    background: #000000;
}

Answer №1

Sequence is significant:

<link rel="stylesheet" href="css/styles.css?v=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

In contrast to

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" href="css/styles.css?v=1.0">

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

Is it commonplace for redux to generate an abundance of storage?

I'm noticing a lot of lines in the terminal, is it really necessary to create so many storage instances? 4. The WrappedApp just created a new store with withRedux(MyApp) { initialState: undefined, initialStateFromGSPorGSSR: undefined } 14:47:39.619 ...

What is the best way to remove the box-shadow from a React-Bootstrap Dropdown Button?

I'm attempting to remove the box shadow or second border from the bootstrap dropdown button when it is clicked. I have been unable to identify the specific class responsible for this change. https://i.sstatic.net/9wxRm.png ...

Coloring vertices in a Three.js geometry: A guide to assigning vibrant hues

This inquiry was previously addressed in this thread: Threejs: assign different colors to each vertex in a geometry. However, since that discussion is dated, the solutions provided may not be applicable to current versions of three.js. The latest versions ...

Upload several files sequentially in a form on a website using Selenium with Python

I need to automate the process of inputting multiple files from a folder into a website and running an online job for each file. Currently, I can only input one file at a time using this code snippet. from selenium import webdriver url = "http://www.exam ...

Stylish slanted divs achieved using Bootstrap 4

I'm currently in the process of constructing a block with 6 slanted divs using Bootstrap. Take a look at the image provided below: https://i.sstatic.net/vvg0b.png After attempting to use rows and columns, I noticed that they weren't aligning co ...

Canvg | Is there a way to customize canvas elements while converting from SVG?

Recently, I encountered an issue with styling SVG graphics dynamically generated from data. The SVG graphic appears like this: https://i.sstatic.net/xvIpE.png To address the problem, I turned to Canvg in hopes of converting the SVG into an image or PDF us ...

NPM's twitter-v2 is throwing a 'TypeError: url_1.URL is not a constructor' error

Currently, my focus is on developing a Twitter bot. I am in the process of posting a Tweet using my account configured to work with Twitter API v2. This involves utilizing NPM's twitter-v2, along with Webpack 5.74.0 and the latest version of NodeJS. ...

Import a JSON file into Parse by reading and parsing it to store in the database

I am currently facing a challenge with parsing JSON data in my Parse Cloud function. After fetching the JSON file, I need to parse the data and populate one of my classes with the results. However, I'm having trouble figuring out how to properly parse ...

I am encountering an error when attempting to import the app from the server.js file in Express

In my server.js file, I have set up an express server and exported the app from it. //server.js require("dotenv").config(); const express = require("express"); const app = express(); const connectToDb = require("./connectToDb ...

Stylesheet failing to respond to CSS Media queries

I have looked at other questions with similar issues and it appears that what's missing in their code is: <meta name="viewport" content="width=device-width, initial-scale=1"> However, I already have this code implemented but still facing probl ...

What is the best way to cut out a portion of a div using CSS?

I have a scaled down version of my project, but it's not quite what I need. I would like the green div to have some transparency so that the content behind both divs is visible (there is none in the example, but there is in my actual project). However ...

Determine the selected radio button

----EDIT---- I am developing a jQuery mobile application and I need to determine which radio button is selected. This is the JavaScript code I'm using: function filter(){ if(document.getElementById('segment1').checked) { aler ...

Modal containing Jquery GalleryView

I am facing an issue with loading galleryView inside a modal. Even though using galleryView on its own works fine, I have been unable to make it work within a modal. Despite looking for solutions in previous posts, I couldn't find anything that fixed ...

The PHP script receives an empty string value passed from JavaScript

I am struggling to pass a string from my JavaScript code to my PHP code. Here is the code snippet that triggers when I hit Enter in a text input: $('#user').keypress(function(e) { if(e.which == 13) { var val = $(this).val(); ...

Troubleshooting Bootstrap: Issues persist even after including CDN links and reference style link // Python

Currently, I'm in the process of constructing my Django app. After successfully implementing the login page and homepage, I decided to give my page a much-needed facelift since it looked extremely basic. A big fan of Bootstrap, I've used it exten ...

Using Jquery and CSS to display or conceal table elements depending on viewport width

I am seeking advice for my issue. Here is the code snippet on JSFiddle. I have a list of models and corresponding values that vary across different categories. I have created a simple table to display this data. However, I need to alter the table structur ...

When attempting to make a GET request, Express/Mongoose is returning a null array

I am having trouble retrieving the list of books from my database. Even though I have successfully inserted the data into Mongoose Compass, when I try to fetch it, all I get is an empty array. //Model File import mongoose from "mongoose"; cons ...

Is it acceptable to use a readonly input with an HTML5 datalist?

Within my application, there is an html5 datalist implemented as shown below: <input type="text" list="mydatalist" /> <datalist id="mydatalist"> <option>Option 1</option> <option>Option 2</option> <option> ...

Assign the chosen option value to a PHP variable for storage

Is there a way to assign the selected value of a select input to a php variable? I'm trying to take the value that is selected in a select box and store it in a php variable, then echo out the selected option value. However, I am having trouble access ...

Discover the process of retrieving an element by its ID when dealing with dynamically generated IDs in AngularJS

I am creating a list using the following code snippet: <div ng-repeat="list in fileUploadList"> <div id="{{list}}Upload"></div> </div> Within the controller, I need to retrieve the element by ID, so I am utilizing this line of ...