How to eliminate inline CSS by using div tags

Recently, I reorganized my table that contains submit buttons:

<table style="border: 0; width: 15%">
    <tr style="background-color: transparent">
        <td style="border: 0">
            <form action="displayevalform" method="post">
                <input type="submit" value="Go Back">
            </form>
        </td>                       
        <td style="border: 0">
            <form action="evaluate" method="post">
                <input type="submit" value="Done">
            </form>
        </td>
    </tr>
</table>

However, after removing the inline CSS and moving the table into a <div>, it doesn't seem to work as intended:

<style>
.tblreset table {
    border: 0;
    width: 15%;
}

.tblreset tr {
    background-color: transparent;
}

.tblreset td {
    border: 0;
}
</style>

<div class="tblreset">
    <table>
        <tr>
   <td>
    <form action="displayevalform" method="post">
    <input type="submit" value="Go Back">
    </form>
</td>                       
    <td>
    <form action="evaluate" method="post">
    <input type="submit" value="Done">
    </form>
</td>
</tr>
</table>
</div>

I'm puzzled as to why this new setup is not functioning. Could there be an issue with my CSS syntax?

Answer №1

I made some adjustments to the CSS properties, which appears to have improved the layout:

<html>
  <head>
    <style>
      .tblreset table {
        border: 2px solid yellow;
        width: 25%;
      }

      .tblreset tr {
        background-color: green;
      }

     .tblreset td {
        border: 1px solid blue;
      }
    </style>
  </head>

  <body>
    <div class="tblreset">
      <table>
        <tr>
          <td>
            <form action="displayevalform" method="post">
              <input type="submit" value="Go Back">
            </form>
          </td>                       
          <td>
            <form action="evaluate" method="post">
              <input type="submit" value="Done">
            </form>
          </td>
        </tr>
      </table>
    </div>
  </body>
</html>

Answer №2

After some investigation, I discovered the source of the issue. The layout.css file, which is part of a template, contains styles for elements such as table, tr, th, and td. It became clear that these styles were conflicting with my own tblreset styles. To resolve this conflict, I separated them into a new file called table.css, and now everything is working smoothly.

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 feasible to combine border-radius with a gradient border-image?

I'm trying to style an input field with a rounded border using the border-radius property, and also add a gradient to that border. Despite successfully creating both the gradient and rounded corners separately, I am unable to make them work together. ...

The SVG graphic becomes distorted when I insert it into an HTML document

Recently, I've dived into the world of SVG and I must say, I love it. They are clean, cool, and super easy to design. However, I encountered an issue when trying to integrate one of my SVGs into HTML (it works perfectly with all my SVGs except this p ...

How to Ensure an Element Appears Above Another Despite Z-Index Troubles?

After conducting approximately 2 hours of research on this topic, I was unable to find clear answers or solutions. Hence, I have decided to address the issue here. The problem I'm facing is as follows: Due to the nature of HTML/CSS, it seems impossi ...

Can Xpath be condensed into a more compact form?

Currently, I'm immersed in a project that involves utilizing XPath on HTML. The lengthy XPath is being passed to the client-side using JavaScript. Due to the verbose nature of XPath strings, my curiosity has been piqued about the existence of a more c ...

Is it possible to make an asp:Panel extend beyond its boundaries to the right when dynamically incorporating controls into a webpage?

Currently, I am working on a solution to dynamically add controls to an asp:Panel on a website, ensuring that they all remain on the same line. Despite setting a specific width and adding overflow:auto, the controls still wrap to the next line when there i ...

The filter search feature fails to return any results when data is inputted into the tables

I have implemented a filter search feature within two tables on my website. My goal is to retrieve the search results for a specific drink while keeping the table headings fixed in their positions. For instance, if I type "Corona" into the search box, I ...

"Vue: Elevate Your Design with Seamless Color Trans

I am faced with the challenge of creating a transition effect for an overlay color when a button is clicked using Vue. Currently, the overlay appears abruptly, but I would like it to smoothly transition from a darker shade to a lighter one. As a newcomer t ...

Fade in and out of page or div elements with a simple click

I've been dedicating some time to my recruitment website lately. As a beginner in coding, I'm looking for a script that will automatically fade out the Employment review content when clicking on each employment vacancy div and then fade back in w ...

Implementing Validation for DropdownChoices and Checkboxes in Wicket Java

There is a checkbox and dropdown menu on an HTML page. Upon clicking submit, if both are selected, there should be an error message stating that at least one of them is mandatory and prompting the user to select at least one value. To address this issue, ...

Blocking Cross-Origin Requests - Interfering with .net Web API and JavaScript AJAX

My current project involves implementing Ajax to capture a submit event and then send the form elements formatted as JSON to an asp.net Web API 2. I am using the latest version of Firefox with the ad blocker disabled, and there is SSL on both the origin an ...

Having trouble getting a resizable DIV inside a 100% height DIV with margin to work properly. Any tips or assistance would be greatly

I've encountered a common issue that is slightly different from others I've come across. Despite my best efforts, I have been unable to find a solution on my own. If anyone could offer me some guidance on this, I would greatly appreciate it. The ...

The third @media query for max-width is not functioning as expected in the CSS

Looking to create a responsive card section on my website for various screen sizes. The goal is to display 5 cards per row when the screen width is greater than 1300px, maintain 3 cards per row from 1024px to 1300px, and then switch to only 2 cards per row ...

Persistent JavaScript animation loop troubles

Hey there, I'm new to web development and I've been working on a simple webpage with a text animation that moves from the top of the screen to the middle when the page loads. The animation itself is working fine, but I'm having trouble stopp ...

The level of transparency linked with text in a blockquote

I've spent hours on this and I'm completely lost. Even though I believe my code is correct, it keeps telling me it's wrong. I don't know where to go from here. The task requires adding a style rule for the blockquote element that chan ...

Creating an art piece on canvas using Javascript based on an image selection

Using the webpage below, I am attempting to draw a photo selected with an iPhone on the canvas so that it can be later uploaded to a webpage via ajax. The code includes downsampling, which has been omitted for simplicity. While this code works perfectly i ...

How can I use JavaScript to consistently fetch the CSS-defined percentage setting for padding/margin instead of the pixel size?

How can I retrieve the padding set in CSS for a div with {padding:10% 10px 20% 10px;} using JavaScript, considering that window.getComputedStyle(myelement).getPropertyValue('padding'); returns different results? In Firefox, it shows as "10% 10px ...

Ways to animate a main element independently of its counterpart's animation

I want to create an animation for a parent element without affecting the child's animation. My HTML & CSS structure is set up as follows: .parent{ background-image: url('https://pm1.narvii.com/6195/421ddbf8c9a2fb1715ef833f869164dc1be ...

Need help automating clicking the download csv button with Selenium Python, but the button's class name changes when it's hovered over?

While attempting to save a csv file by clicking the download csv button on a website, I encountered an issue. It seems that the .click() action is not functioning as expected, and upon inspection, I noticed that the class-name of the button changes from &a ...

Can animations be stacked in a queue while using velocity.js?

I'm currently tackling a project involving a push menu. When the content div slides over, the menu buttons come in with a slight animation as they appear on the screen. However, if the user rapidly opens and closes the menu multiple times, the items o ...

Shorten/Alternate coding:

Sometimes, creating the content section of a website can be time-consuming. I recently spent half a day crafting the index page of my website at . However, when attempting to add an additional image to the list of six already present, it turned into a leng ...