What's the best way to ensure my website's footer spans the entire width of the webpage?

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <title>Elena Brown | Graphic Designer</title>
        <link rel="stylesheet" href="CSS/normalize.css">
        <link href='http://fonts.googleapis.com/css?family=Quicksand' rel='stylesheet' type='text/css'>
        <link href='http://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' type='text/css'>
        <link rel="stylesheet" href="CSS/main.css">
        <link rel="stylesheet" href="CSS/responsive.css">

    </head>

    <body>

        <header>

            <a href="index.html" id="logo">
                <h1>Elena Brown</h1>
                <h2>Graphic Designer</h2>
            </a>

            <nav>

                <ul>
                    <li><a href="about.html"class="selected">About</a></li>
                    <li><a href="portfolio.html">Portfolio</a></li>
                    <li><a href="contact.html">Contact</a></li>
                </ul>

            </nav>
        </header>
        <div id="wrapper">
        <section>
            <ul id="gallery">
                <li id="pic1">
                    <a href="img/Elena.jpg">
                    <img src="img/Elena.jpg" width="500" height="400" alt="">
                    <p> This is me </p>
                    </a>
                </li>
                <li id="pic2">
                    <a href="img/Creativity.jpg">
                    <img src="img/Creativity.jpg"width="500" height="400"  alt="">
                    <p> Exploring creativity in design </p>
                    </a>
                </li>
                <li id="pic3">
                    <a href="img/Typography.jpg">
                    <img src="img/Typography.jpg"width="500" height="400" alt="">
                    <p> Playing with typography</p>
                    </a>
                </li>
                <li id="pic4">
                    <a href="img/Colors.jpg">
                    <img src="img/Colors.jpg"width="500" height="400" alt="">
                    <p>Embracing the world of colors</p>
                    </a>
                </li>
            </ul>
        </section>
        <footer>
            <div id="mus">
            <embed src="Neo.mp3" loop="true" autostart="true" height="55mm">
            </div>
            <div id="logo">
            <a href="https://www.instagram.com/elena.brown.designs">
            <img src="img/instagram.png" alt="Instagram Logo" class="icon">
            </a>
            <a href="https://twitter.com/ElenaBrownDes">
            <img src="img/twitter.png" alt="Twitter Logo" class="icon">
            </a>
            </div>
            <p>Elena Brown</p>
            <p>All Rights Reserved.</p>
        </footer>
      </div>
    </body>
</html>

My Custom CSS Styles

a {
    text-decoration: none;
}

#wrapper {
    max-width: 940px;
    margin: 0 auto;
    padding: 0 5%;
}

#logo {
    text-align: center;
    margin: 0;
}

h1 {
    margin: 0;
    padding-top: 4mm;
    font-size: 2em;
    font-family: 'Montserrat', sans-serif;
    font-weight: normal;
    line-height: 0.8em;
}

h2 {
    font-family: 'Quicksand', sans-serif;
    font-size: 1.5em;
    margin: -5px 0 0;
    font-weight: normal;
}

body{
    font-family: 'Quicksand', sans-serif;
}

a {
    color: #FF5733;
}

header{
    background: #FF5733;
    border-color:#DB893D;
    float: left;
    margin: 0;
    padding: 5px 0 0 0;
    width: 100%;
}

nav{
    background:  #DB893D;
    text-align: center;
    margin: 20px 0 0;
}

nav a, nav a:visited {
    color: #fff;
}

nav ul{
    list-style: none;
    margin: 0 10px;
    padding: 0;
}

nav a{
    font-weight: 800;
    padding: 15px 10px;
}

h1, h2{
    color: #fff;
}

nav a.selected , nav a:hover {
    color: #B35834;
}

footer{
    font-size: 1em;
    text-align: center;
    clear: both;
    padding-top: 20px;
    color: #ccc;
    line-height: 0.8em;
    background: black;
    margin: 0;
}

img{
    max-width: 100%;
}

#gallery{
    margin: 0;
    padding: 0;
    list-style: none;
}

#gallery li{
    float: left;
    width: 45%;
    margin: 2.5%;
    background-color: #f5f5f5;
    color: #bdc3c7;
}

#gallery li a p{
    margin: 0;
    padding: 0;
    font-size: 1.5em;
    color: #bdc3c7;
}

.icon{
    width: 40px;
    height: 40px;
    margin: 5mm 5px;
}

body{
    background: lavender;
    margin: 0;
    color: #333;
}

Can someone help me troubleshoot why the footer is not taking up the full width of the webpage? I've tried setting the max-width and width to 100%, but it's not working. Any suggestions on how to make the footer span the entire width of the page?

Answer №1

The placement of your footer within the div.wrapper needs to be adjusted. Please relocate it outside of the div container and adjust the margin accordingly.

Answer №2

Here is your current HTML structure:

<div id="container"> ... <footer> .. </footer> </div>

You need to move the footer outside of the container div like this:

<div id="container"> ... </div> <footer> .. </footer>

View Demo

Answer №3

<!DOCTYPE html>
<html>
    <head lang="en">
        <meta charset="utf-8">
        <title>Lucy Smith | Graphic Designer</title>
        <link rel="stylesheet" href="CSS/normalize.css">
        <link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
        <link href='http://fonts.googleapis.com/css?family=Montserrat' rel='stylesheet' type='text/css'>
        <link rel="stylesheet" href="CSS/main.css">
        <link rel="stylesheet" href="CSS/responsive.css">

    </head>

    <body>

        <header>

            <a href="index.html" id="logo">
                <h1>Lucy Smith</h1>
                <h2>Graphic Designer</h2>
            </a>

            <nav>

                <ul>
                    <li><a href="about.html"class="selected">About</a></li>
                    <li><a href="portfolio.html">Portfolio</a></li>
                    <li><a href="contact.html">Contact</a></li>
                </ul>

            </nav>
        </header>
        <div id="wrapper">
        <section>
            <ul id="gallery">
                <li id="pic1">
                    <a href="img/Lucy.jpg">
                    <img src="img/Lucy.jpg" width="500" height="400" alt="">
                    <p> This is me </p>
                    </a>
                </li>
                <li id="pic2">
                    <a href="img/Passion.jpg">
                    <img src="img/Passion.jpg"width="500" height="400"  alt="">
                    <p> This shows my passion </p>
                    </a>
                </li>
                <li id="pic3">
                    <a href="img/Creativity.jpg">
                    <img src="img/Creativity.jpg"width="500" height="400" alt="">
                    <p> This displays my creativity </p>
                    </a>
                </li>
                <li id="pic4">
                    <a href="img/Design.jpg">
                    <img src="img/Design.jpg"width="500" height="400" alt="">
                    <p> This showcases my design skills</p>
                    </a>
                </li>
            </ul>
        </section>
      </div>
    <footer>
        <div id="music">
        <embed src="Beats.mp3" loop="true" autostart="true" height="55mm">
        </div>
        <div id="socials">
        <a href="https://www.facebook.com/lucysmith.designer">
        <img src="img/facebook.gif" alt="FaceBook Logo" class="icon">
        </a>
        <a href="https://twitter.com/LucyDesigner">
        <img src="img/twitter.png" alt="Twitter Logo" class="icon">
        </a>
        </div>
        <p>Lucy Smith</p>
        <p>All Rights Reserved.</p>
    </footer>
    </body>
</html>

Utilizing jsFiddle

Remember to remove the ... from outside your main DIV

Answer №4

check out this code:

custom CSS styling

footer{
font-size: 1em;
text-align: center;
clear:both;
margin:0;
}

.footer_content{
width: 100%;
position: absolute;
left: 0;
font-size: 1em;
text-align: center;
clear:both;
padding-top: 20px;
color: #ccc;
line-height: 0.8em;
background: black;
margin:0;
}

HTML structure

    <footer>
        <div class="footer_content">
        <div id="mus">
        <embed src="Neo.mp3" loop="true" autostart="true" height="55mm">
        </div>
        <div id="logo">
        <a href="https://www.facebook.com/jackyuan.jack">
        <img src="img/facebook.gif" alt="FaceBook Logo" class="icon">
        </a>
        <a href="https://twitter.com/Jack19909100">
        <img src="img/twitter.png" alt="Twitter Logo" class="icon">
        </a>
        </div>
        <p>Jack Yuan</p>
        <p>All Rights Reserved.</p>
        </div>
    </footer>

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

Guide to display half of an image and allow for full image viewing upon mouse hover

After creating my bootstrap 4 website, I encountered an issue with the code below where only half of the image is displayed initially due to a conflict in the code. It also fails to work properly when moving the mouse after shifting the whole image from ri ...

Navigate down the page until you reach the section that is set to display as a block

Is it possible to make the page automatically scroll to a specific element located in the middle of the page when changing its display property from none to block? ...

I am interested in incorporating jQuery into my React development project

I'm trying to implement jQuery in React. I have an input field in my project that I am using to create a match event with 'this.state.value'. When the content of the input field matches, I want the borders to turn green and red if they do no ...

Interactive image popups with JavaScript

Seeking assistance in generating a popup when selecting an area on an image map using Javascript. As a novice in JS, I have successfully implemented popups for buttons before but encountered issues with this code within the image map - the popup appears br ...

Viewing the details of a checkbox option

I have encountered a situation where I need to handle detail rows within a table that contain checkboxes for selection. The desired behavior is: 1) When clicking on the detail row image, it should expand to show the details of its parent row without sele ...

Conceal the block quotes while substituting with a newline

My HTML page contains numerous comments enclosed in blockquotes. I attempted to implement a feature that allows users to hide all the comments with just one click by using the following JavaScript code: const blockQuotes = document.getElementsByTagName(& ...

Flask: BadRequestKeyError: 400 Bad Request: The server was unable to comprehend the request sent by the browser (or proxy)

When I try to link to the edit view in my birthday reminder app, I keep getting a key error. The get_Gift function returns an object with the key field present and the HTML form has all the necessary fields, so I'm not sure why this error is occurring ...

Changing the size of a responsive navigation bar with React and adjusting it based on the window.scrollY position switches between collapsed and un

I'm struggling to create a responsive navbar that automatically adjusts its size once it surpasses the height of the navbar (currently set at 80px). However, when I scroll to around the 80px mark, it starts flickering between the collapsed and expande ...

What could possibly be causing the 500 server error in PHP?

It's frustrating - every time a user tries to enter their email and password, an error 500 message pops up on the server! But strangely enough, upon refreshing the page, everything seems to work just fine... So why does the server throw an error on th ...

Problem with looping through arrays in JQuery using .each() function

Looking for some help with jQuery and JavaScript, please bear with me if my question seems naive. I am attempting to load images from different folders into corresponding divs to create a gallery. <div id="menu"> <div class="gallery" id="div0"&g ...

Display the execution duration on an HTML document

Recently, I created a loan calculator using Javascript and now I'm contemplating on incorporating the time taken for the code to execute into the results. My intention is to have the execution time displayed on my HTML page, but I am unsure of how to ...

JavaScript popup cannot be shown at this time

I'm encountering an issue with displaying popups using JavaScript. Currently, only the div with class "popup" is being shown. When a user takes action, both popup and popup2 should be displayed but for some reason, it's not working as expected. ...

Can we incorporate modulo into the loop?

I have a JavaScript function with HTML code inside. I need the ".one-card" div to repeat four times within each ".row" div. The ".row" div is being repeated in a foreach loop. I want to check if the result of modulo (4) is not equal to zero, then display t ...

Struggling with using flexboxes and creating animated elements

Seeking assistance with animating the search bar on a website project. The animation is functioning, but the search input abruptly moves when the animation starts, as shown in this GIF: I am utilizing jQuery for the animation because I also want to implem ...

Inspecting JavaScript for any attachments

Before hitting the submit button, I need to verify if a file has been uploaded and display a warning message prompting the user to attach a file if it hasn't been done yet. I am looking for guidance on how to achieve this using JavaScript, Prototype, ...

Emphasize entries in an index that match the currently visible content as you scroll

I have a table of contents in my HTML page with the CSS attribute position: fixed;. I want to emphasize the current reading position by highlighting it (bold or italics) as I scroll down the page. | yada yada yada ... 1. Secti ...

Leveraging static elements in a fluid design using solely CSS whenever feasible

Here's a question that requires some logical thinking rather than technical expertise. I've created a design where the header and footer are always fixed at the top and bottom of the window, respectively. However, the elements inside have percen ...

Attempting to isolate just a fragment of the inner content

Option Explicit Sub VBAWebscraping2() Dim IEObject As Object Set IEObject = New InternetExplorer IEObject.Visible = True IEObject.navigate url:="https://streeteasy.com/building/" & Cells(2, 4).Value ...

The arrangement of CSS code is crucial for it to work properly; any deviation from the correct order

I am facing a problem where I am trying to display a circular div using CSS, but it only works if the background image property is set first. Typically, this wouldn't be an issue if the image wasn't being dynamically inserted using PHP code. I ...

Where to position a button in the middle of a div that varies in size

I'm currently working with this code snippet: <div class="outer"> <ul class="list"> <li class="inner"> <div class="line">information1</div> <div class="line">hyperlink1</div&g ...