I aim to have just the footer section perfectly aligned within the screen, without the entire body extending beyond

I am encountering an issue with the footer tag once again. I need this section to occupy the entire screen, without affecting the rest of the body content. That is why I omitted setting margin:0; for body elements.

I attempted to apply margin:0 to the footer, but it did not yield the desired result (highlighted in the image). How can I resolve this issue?

Here is the CSS code for my footer:

footer {
 padding: 5vw;
 margin: 0px;
 background-color: #DCEDC8;
 color: black;
 font-size: 4vw;
 text-align: center;
 font-weight: bold;
}

[1]: https://i.sstatic.net/kCczY.jpg![ The footer does not stretch across the screen correctly](https://i.sstatic.net/dblej.jpg)

Answer №1

Your current issue stems from the default margin set on the body element, affecting all elements within it (including your footer).

To resolve this, you should add margin: 0 to the body and enclose your content within a container div (with its own margin).

Place your footer outside the container with a margin of 0.

body {
  margin: 0;
}

.container {
  margin: 8px;
  background-color: #9f9f9f;
}

footer {
  margin: 0;
  background-color: #ff5555;
}
<!DOCTYPE html>
<html>

  <head>

  </head>

  <body>
    <div class="container">
      Your content goes here. Please note the margin surrounding this div.
    </div>
    <footer>
      Your footer goes here. No margin surrounds this footer.
    </footer>
  </body>

</html>

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

Generating a dynamic method for uploading multiple files

Is there a way to dynamically generate multiple upload forms upon clicking a button? I currently have code that allows for uploading one file, but I would like to be able to add additional forms for each file. In other words, if I need to upload 7 files, I ...

Enhance your AngularJS table with a custom Javascript context menu!

In the process of developing a shift planner, I have implemented a JS context menu and am attempting to display the shifts using Angular. However, upon clicking any table cell, all cells are being updated simultaneously. Is there a workaround for this issu ...

Is there a way to keep my fixed button at a consistent size while zooming on mobile devices?

There are no definitive answers to the questions regarding this issue. Some suggest stopping zoom altogether, while others recommend setting the width, which may not always solve the problem. I am working on a web application designed for mobile use with ...

What is the best way to create a gallery using Bootstrap 4?

I'm currently working on a project for my homework that involves replicating a car brand page, but I've hit a roadblock at this particular section. https://i.stack.imgur.com/0Zfr5.jpg My goal is to recreate the gallery using a .container with n ...

Parsing text files with Highcharts

As a beginner in JavaScript and HighCharts, I am facing a simple problem that has me completely lost. My goal is to generate a scatter chart with three lines by reading data from a text file formatted like this: x y1 y2 y3 1.02 1.00 6.70 ...

"Trouble with making jQuery AJAX calls on Internet Explorer versions 8 and 9

I've been searching for the answer to this problem without any luck. I have a page with jquery ajax calls to an API service. It works well in Chrome, Safari, Firefox, and IE 10, but fails in IE 9 and 8. Here is the code: $.ajax({ ...

Is it possible to have the Target='_blank' attribute open the link in a new window instead of a new tab?

Is there a way to achieve this? When using Firefox, the link opens in a new tab, which I prefer to avoid users having to adjust settings in their browsers. I am looking for a solution where a pop-up contact form appears whenever a user clicks on 'co ...

What could be causing my difficulty in locating an HTML element using jQuery/JS string interpolation?

In my project, I have a set of div blocks each identified by a unique numerical id. For instance: https://i.sstatic.net/lYod8.png One of the tasks in my project is to select the 29th element following a specific chosen element. For example, if I choose t ...

Guide to organizing an HTML table column with a header click using PHP and MySQL

I am currently working on a table that displays data from a MySQL database. I would like to implement functionality that allows users to click on certain columns to sort them in ascending or descending order. However, I am unsure of whether to use PHP, H ...

The information overflow occurs outside the tooltip specifically in Chrome, while functioning perfectly in IE11

As a newcomer to the CSS world, I am experimenting with adding a block-level element (div) inside an anchor tag's :hover pseudo-class popup. The div element contains a table that needs to have dynamic sizing for both the table itself and its cells (wi ...

When scrolling the page, the onscroll event is activated two times

While practicing a tutorial on modal windows, I came across an interesting issue. After triggering an "onscroll" event at the end of the page and closing the modal window, the event stopped firing. This made me curious as to why the author would include lo ...

Whiskey Angostura and Straight Row Set to 8, not 12

Recently, I incorporated Bourbon, Bitters, and Neat into my rails application. However, I am encountering an issue where the number of grid-columns is stuck at 8 instead of the desired 12. To address this problem, I have taken the following steps: Ensur ...

(Material UI version 5) Custom global style enhancements

One of the examples in MUI is the Global style overrides: const theme = createTheme({ components: { // Name of the component MuiButton: { styleOverrides: { // Name of the slot root: { // Some CSS fontSize ...

Having trouble embedding the video in an iframe. Any tips on how to make it work?

I have encountered an issue while trying to embed a video in my WordPress site using an iframe. The video is not displaying completely on the page, with only the left part visible and the rest being cut off. Here is the code I am currently using: <P A ...

Unlocking the AngularJS variable within the template script

My controller code: $scope.totals = totals; In the template, I am able to successfully inject HTML using this code: {{totals}} However, my goal is to access the totals variable in a script within the template. Here's what I attempted: <script& ...

Initiating the accordion feature requires two clicks and triggers an rotation of the icon

I managed to integrate some code I discovered for a FAQ accordion on my website. I am struggling with getting the title to expand with just 1 click instead of 2. Additionally, I would like the icon to rotate when expanding/collapsing, not just on hover. Be ...

Utilizing Node-Red: Linking an External CSS File with HTML Elements

If there are any resources on this particular topic available on the Node-Red website, please share them with me. My current project involves building a static website using HTML, JavaScript, and CSS with Node-Red. I am utilizing HTTP GET nodes to call my ...

Use JQuery version 1.8 or above to link the mousewheel

Currently, my website is utilizing Jquery 1.8.3. Unfortunately, I am facing an issue where I am unable to bind the mousewheel with this version of jQuery, while the 1.4.2 version successfully binds the mousewheel. I am seeking a solution to overcome this ...

What could be causing the HTML <DATALIST> dropdown to display next to its input rather than below it?

I have an input linked to a datalist, and it's functioning correctly. However, when I initially open the dropdown, the option list appears next to (right of) the input. After entering a few characters to narrow down the list, it then shifts below the ...

Implementing AngularJS drag and drop functionality in a custom directive

I am in search of an example that demonstrates similar functionality to the HTML5 File API using Angular-js. While researching directives for Angular 1.0.4, I found outdated examples that heavily rely on DOM manipulation. Here is a snippet of the pure Ja ...