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

Show picture during the process of loading an external webpage

Utilizing a script to load an external page (external meaning a page within my website) inside a div. Loading the page takes time, so I want to display an image until the page is fully loaded. JAVASCRIPT function HideLoader() { $('#loader' ...

Image-switching button

I'm new to JavaScript and struggling with my first code. I've been staring at it for two days now, but can't figure out what's wrong. The goal is to create an HTML page where the user can change an image by clicking on a button, and th ...

What is the best way to adjust text to a specific width on an HTML canvas?

Is there a way to adjust the width of a single-line text string precisely on an HTML5 canvas? My current method involves initially setting a font size, measuring the text's width using measureText(my_text).width, and then determining a new font size b ...

Attempting to assign a specific font style to a dropdown selection menu

Trying to assign a font-family to the options in my select menu but facing issues. The code below seems to work on Google Chrome, but I'm getting a different font-family on Internet Explorer. Any suggestions on how to set a font-family that works on ...

Enhance your Angular material datepicker with additional content such as a close button

I'm currently working on customizing my Angular Material datepicker by adding a button. The goal is to have this button placed in the top right corner and enable it to close the datepicker when clicked. In addition, I also want to include extra conte ...

Setting the path to an image component using the style jsx tag in Next.js: A step-by-step guide

While utilizing jsx to define styles for my NextJs components, I am facing the challenge of defining a background image for certain elements. I have realized that only relative paths or absolute paths are accepted. But how can I pass a relative path to th ...

In order to add value, it is necessary to insert it into the text box in HTML without using the "on

example <input type="text" id="txt1" onChange="calculateTotal();" /> <input type="text" id="txt2" onChange="calculateTotal();" /> <input type="text" id="txt3" onChange="updateValue();" readonly/> <input type="text" id="txt4" onChange= ...

How to Incorporate an Anchor Link into a Div as well as its Pseudo Element using CSS, Javascript, or jQuery

How can I make both the menu item and its icon clickable as a link? When either is clicked, the link should work. Here is a CodePen example: http://codepen.io/emilychews/pen/wJrqaR The red square serves as the container for the icon that will be used. ...

Issue with retrieving the current location while the map is being dragged

How can I retrieve the current latitude and longitude coordinates when the map is dragged? I've tried using the following code: google.maps.event.addListener(map, 'drag', function(event) { addMarker(event.latLng.lat(), event.la ...

What is the best way to iterate through only the selected checkboxes to calculate their

I am in need of calculating the selected checkboxes only within a table field (harga_obat*jumlah) Below is my foreach data: @foreach ($obat as $o) <tr> <td> <input id="check" type="checkbox" name="select[]" value="{{ $o->nam ...

Manipulate inherited CSS styles from an external source

Currently, I am working on creating a pagination using the NG-Bootstrap pagination component. However, I encountered an issue where I need to modify or specifically remove some CSS properties that are applied by default in the NG-Bootstrap library. Is ther ...

Toggle nested menu within another submenu

Looking for help with toggling menu items? I currently have a menu setup with 3 icons where clicking on an icon opens the dropdown-mobile UL under it. The goal is to toggle different submenu items when 'Main menu item' or 'sub-menu item&apos ...

Background wrapper does not reach full height of page

I am currently dealing with a website template that has a background image in the wrapper. However, when I view the site on a 13" laptop screen, the text extends below the fold because the wrapper only covers above the fold. This results in my content not ...

HTML File Path for C Drive

I am a beginner with HTML and I'm facing an issue regarding displaying an image located at "C:\Users\Jas mine\folder\landscape.jpg" in HTML. I have tried various solutions posted by others but none of them seem to work for me. Can ...

An artistic arrangement of images seamlessly fitting together in a rectangular shape using HTML and CSS

I am currently working on creating a collage of images that need to fit perfectly within a rectangle. I have successfully completed the top layer, but I am facing some confusion with arranging the images in the last row using CSS. (For better visualization ...

Can login data be transferred from the index page to other pages?

Working on a school project involving a Weather info web page has been quite the journey. Most of it is complete, except for one issue that I can't seem to figure out. The index page with login and registration functions is connected to phpmyadmin/mys ...

ejs-lineargauge major divisions and minor divisions centered

I've been trying to align majorTicks and minorTicks in the middle of the axis, but so far I haven't found a solution despite searching and googling extensively. Here's a snippet of my code: majorTicks: { height: 12, interval: 1, width ...

The differences between using the opacity attribute in HTML and the opacity property

There are two distinct methods for adjusting opacity in HTML: <div opacity="0.5"></div> and <div style="opacity: 0.5;"></div> I am familiar with setting these values in JavaScript as well: div.setAttribute("opacity", 0.5); and ...

Show a pop-up notification for a compact disc

Received a CD containing various tutorials created in HTML. I am looking to have a browser window open with specific parameters, such as no toolbars and fixed width/height, to properly display the content. Using window.open with multiple parameters trigge ...

Is there a way to eliminate the white background or border on my Font Awesome checkbox?

One issue I'm encountering with Font Awesome 5 is that, when I click on my checkbox, there is an unwanted white background or border that I can't seem to get rid of. /* Updating default snippet color for better visibility of the issue */ body ...