Why does the styling on my <a> tags in the footer only take effect when I apply padding to the form above?

It seems that when styling the <a> tag for the list in the footer, no changes occur even if correctly applying the style. However, adding padding to the form in the main part of the code causes the links in the footer to show the change.

To see this behavior, refer to line 56 in the CSS section of the JSfiddle (https://jsfiddle.net/wk47q0en/) and comment out/delete the random padding added to the form. You will notice that the footer styling disappears. The reason behind this inconsistency is puzzling.

For those wondering, yes, I am new to HTML and CSS; this is all part of some homework. Thank you in advance for any advice or insight provided to help clarify this issue.

https://jsfiddle.net/wk47q0en/

HTML

 <meta charset="utf-8">
    <title>Red Pepper Pizza</title>
    <link rel="stylesheet" href="style.css">
  </head>
  <body>

    <div class="topmenu">
      <nav>
        <ul>
          <li><a href="#">Home</a></li>
          <li><a href="#">Menu</a></li>
          <li><a href="#">Weekly deals</a></li>
          <li><a href="#">Resturants</a></li>
          <li><a href="#">Contact us</a></li>
        </ul>
      </nav>
  </div>

  <form action="example.htm" method="get">
    <fieldset>
      <legend>Order your pizza below</legend>
      <select name="Pizza" id="Pizza">
        <option value="selected" selected>Choose a pizza</option>
        <option value="Pepperoni">Pepperoni</option>
        <option value="Ham">Ham</option>
        <option value="Vegan">Vegan</option>
        <option value="Margarita">Margarita</option>
      </select>

      <p>Choose your Pizza crust</p>
      <input type="radio" name="Crust" value="Thick"> Thick
      <input type="radio" name="Crust" value="Thin"> Thin

      <p>Extra toppings</p>
      <input type="checkbox" name="Toppings" value="Onions"> Onions
      <input type="checkbox" name="Toppings" value="Salmon"> Salmon
      <input type="checkbox" name="Toppings" value="Garlic"> Garlic
      <input type="checkbox" name="Toppings" value="Olives"> Olives
      <input type="checkbox" name="Toppings" value="Chilli"> Chilli
      <input type="checkbox" name="Toppings" value="Peppers"> Peppers

      <textarea name="comment" rows="8" cols="62"> Additional specifications...</textarea> <br>

      <input type="submit" name="order" value="order">
      </fieldset>
  </form>

    <footer>
        <div class="footermenu">
           <ul class="footlist">
             <li><a href="#">Contact us</a></li>
             <li><a href="#">Privacy</a></li>
             <li><a href="#">Job oppertunities</a></li>
             <li><a href="#">Allergens</a></li>
             <li><a href="#">Blog</a></li>
           </ul>
       </div>
      </footer>
      </body>
    </html>

CSS

    /* body etc */
    @font-face {
    font-family: 'Roboto', sans-serif;
    src: url(assets\RobotoFont\Roboto-Regular.ttf);
    }

    body {
      font-family: 'Roboto', sans-serif;
      margin: 0;
      padding: 0px 10px;
    }

    /* Navigation/topbar/sidebar */

    ul {
      margin: 0px 0px 0px 0px;
      list-style-type: none;
    }

    li {
      display: inline;
    }


    .topmenu {
      width: 100%;
      background-color: #d12d17;
      height: 40px;
      text-align: center;
      margin-top: 0px;
      padding-top: 0px;
    }


    .topmenu a {
      display: inline-block;
      height: 40px;
      color: black;
      text-decoration: none;
      font-size: 19px;
      font-weight: bold;
      padding: 10px 25px;

    }

    .topmenu a:hover {
      transform: scale(1.3); }
    }


    /*Header and intro*/




    /* Form elements*/

    form {
      padding: 0 50%;
    }



/*footer */

.footlist a {
  display: inline-block;
  height: 40px;
  color: black;
  text-decoration: none;
  font-size: 15px;
}

Answer №1

It appears there is an issue with your CSS code on line 48 where an extra curly bracket is present. This error is causing the form element on line 58 to not receive the intended styling, although subsequent elements appear to be styled correctly. Removing the form element styling reveals that the error then affects the following element, specifically the link in the 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

Navigation that sticks and changes upon hovering over div elements

Just delving into the world of jQuery and JS, so I appreciate your patience:) Currently, I have a sticky navigation bar positioned at the top of my webpage that links to different sections of content below. I am looking to create an effect where the corr ...

Using Google-Prettify with AngularJS

I have been attempting to implement Google Prettify in my AngularJS project. It seems to be functioning correctly on the main page, but once I navigate to another route using Angular (after ng-view), it stops working properly. You can check out the plunker ...

Adjust the container width to match the width of the visible thumbnails?

Take a look at my website over at: . If you want to see more thumbnails, consider switching to a different album. The album titled Paris contains the most images. If you press the "Show Photo Grid" button located in the bottom-right corner, you'll be ...

The React Bootstrap modal refuses to fully close no matter how many times I click away or even on the close button

I am facing an issue with a modal in my React component. When I open the modal, it does not completely close when I try to click away or hit the close button. The backdrop disappears but the modal itself remains on the screen. (Screenshots attached for r ...

Are there any CSS hacks available to address the combination of position: sticky and overflow within the parent element?

I've encountered a sticky position issue when the overflow property is set to auto on a parent element. I've tried various solutions like adding an extra wrapper or using clip instead of auto, but none have worked. While I did find a solution usi ...

Animation does not trigger before switching pages

I'm attempting to create an animation that occurs before the page transitions. After finding a jQuery script on this site and tweaking it to match my HTML, I realized the code works in a fiddle but not on my actual page. Any assistance would be greatl ...

Centering text using CSS Bootstrap

Hey everyone, I've been attempting to center my text using Bootstrap, but for some reason it's not working. Can someone help me figure out what's going on? <footer class="row p-1 mt-3 bg-primary text-white"> <p class= ...

The container or row I placed in the middle of the page content is not anchored to the bottom like it should be for footer widgets

I'm struggling with the code I've extracted. How can I move the footer widget to the bottom of the page? On some pages, the footer displays at the bottom because there isn't much content, but on one specific page, it appears in the middle of ...

The rotation of an image in Microsoft Edge results in an HTML file display

One of the images on my website is sourced like this: <p> <img src="images/image.jpg" style="width: 50%;" /> </p> Surprisingly, in Chrome and Firefox, the image looks fine (just how I uploaded it to the server). H ...

The system encountered an issue with the CSS code, indicating "Invalid CSS after "...inear-gradient(": expected selector, was "{"

While attempting to compile my sass code, I encountered the following error message regarding a syntax issue: /* { "status": 1, "file": "C:/Users/faido/Desktop/Productivity/sass css/project/sass/main.sass", "line": 36, "column": 9, "mes ...

Issue with Angular controller failing to load when link is clicked

I am currently developing a webpage that incorporates Angular and responds to ajax requests by populating data into a table. When I manually enter the address, everything works as expected. However, if I navigate to the page using a link ( <a href="/pro ...

Issues with Iframe { height:70%;} in Internet Explorer 8 and Firefox causing display problems

In my website's design, I have a div structure with an iframe to load pages. The header remains at the top seamlessly The footer stays at the bottom perfectly The content is positioned in the middle flawlessly However, the iframe does not stret ...

Utilizing WebElement.findElements() in Selenium to refine search outcomes

After iterating through a list of WebElements, which I refer to as 'graphs', and finding descendants within each graph, I am encountering an issue where similar descendants from different graphs are being included in the results. Currently, I am ...

Tips for setting a specific height for an HTML table

For some reason, I can't seem to control the height of this table. I've set it to a maximum of 20px but all the rows are still showing. Here is the CSS: table { border:1px solid black; overflow:hidden; height:20px; max-height:20 ...

Is there a way to remove this annoying double Google search bar?

Looking to replicate the Google home page for a project using HTML and CSS. I'm having trouble with incorporating the highlighted code (as shown in the second picture and identified by bold and italicized text) into my code. When I try to add it, I en ...

Problems revolving around the fundamental CSS drop-down menu concept

I'm struggling to center a CSS drop-down menu on my webpage without causing the drop-down effect to break. No matter what I try, it seems to mess up. What am I missing? Snippet of code: html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,b ...

Using Javascript to iterate through and increase HTML code with values all the way up to 55

I am looking for a way to automatically generate a list of links in an HTML page using JavaScript. I have tried a few scripts, but none have worked for me. This is the current structure of my HTML... <a href="1.html"><img src="images/1.jpg" widt ...

The header section on a website not behaving as expected in the Chrome browser

For my website, I want it to look like this in Internet Explorer: https://i.stack.imgur.com/hSkVM.png ^^ This is the IE view However, in Chrome, it displays like this: https://i.stack.imgur.com/noQw8.png The issue is with the Top bar on Chrome showing co ...

Verify the authenticity of a date using the locale parameter in the Intl API

Seeking advice for validating inputfield based on locale argument. How to format dates differently depending on the specified locale? For example, if locale is 'en-uk' then date should be in mm/dd/yyyy format, but if locale is 'de-ch' i ...

Aligning text to the center and having it displayed on either side of it

Hey there, I need help with the following: <div id='1'></div> <div id='2'></div> <div id='3'></div> I want to place a single word into each div. The width of each div should be ...