Building a Table Using HTML and CSS

I'm currently tackling this school assignment and have hit a roadblock with two issues.

The HTML Validation error I'm encountering is regarding a table row that is 5 columns wide, exceeding the established count by the first row (4). From line 72, column 5; to line 72, column 9

There seems to be an extra small column at the end of the table, and I'm unsure how to remove it.

table {
margin: auto;
border: 1px solid #3399cc;
width: 90%;
border-collapse: collapse;
    }

    td, th {
padding: 5px;
border: 1px solid #3399cc;
    }

    td {
text-align: center;
    }

    .text {
text-align: left;
    }

    tr:nth-of-type(even) {
background-color: #f5fafc
    }
<table>
  <tr>
    <th id="package-names">Package Name</th>
    <th id="description">Description</th>
    <th id="nights">Nights</th>
    <th id="cost-per-person">Cost per Person</th>
  </tr>
  <tr>
    <td headers="package-names">Weekend Escape</td>
    <td headers="description" class="text">Two breakfasts, a     trail map, a picnic snack</td>
    <td headers="nights">2</td>
    <td headers="cost-per-person">$450</td>
  </tr>
  <tr>
    <td headers="package-names">Zen Retreat</td>
    <td headers="description" class="text">Four breakfasts, a trail map, a pass for daily yoga</td>
    <td headers="nights">4</td>
    <td headers="cost-per-person">$600</td>
  </tr>
  <tr>
    <td headers="package-names">Kayak Away</td>
    <td headers="description" class="text">Two breakfasts, two hours of kayak rental daily, a trail map</td>
    <td headers="nights">2</td>
    <td headers="cost-per-person">$500<td>
  </tr>
</table>

Answer №1

The mistake lies in the final td line:

<td headers="cost-per-person">$500<td>

The last tag should be a closing tag: </td> instead of <td>

table {
margin: auto;
border: 1px solid #3399cc;
width: 90%;
border-collapse: collapse;
}

td, th {
padding: 5px;
border: 1px solid #3399cc;
}

td {
text-align: center;
}

.text {
text-align: left;
}

tr:nth-of-type(even) {
background-color: #f5fafc
}
<table>
<tr>
<th id="package-names">Package Name</th>
<th id="description">Description</th>
<th id="nights">Nights</th>
<th id="cost-per-person">Cost per Person</th>
</tr>
<tr>
<td headers="package-names">Weekend Escape</td>
<td headers="description" class="text">Two breakfasts, a trail map, a picnic snack</td>
<td headers="nights">2</td>
<td headers="cost-per-person">$450</td>
</tr>
<tr>
<td headers="package-names">Zen Retreat</td>
<td headers="description" class="text">Four breakfasts, a trail map, a pass for daily yoga</td>
<td headers="nights">4</td>
<td headers="cost-per-person">$600</td>
</tr>
<tr>
<td headers="package-names">Kayak Away</td>
<td headers="description" class="text">Two breakfasts, two hours of kayak rental daily, a trail map</td>
<td headers="nights">2</td>
<td headers="cost-per-person">$500</td>
</tr>
</table>

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

The 'refresh' function in jQM listview is causing issues with inset lists

For some reason, I am struggling to understand why this issue is occurring: In jQuery Mobile, I have an unordered list with data-inset="true". Initially, it displays perfectly with rounded top and bottom edges. However, on dynamically adding new elements t ...

Implement a grid layout for columns within the profile section

Each user on my website has a profile tab that displays their submitted posts. To showcase these posts, I utilize the following code: <?php while ($ultimatemember->shortcodes->loop->have_posts()) { $ultimatemember->shortcodes->loop-> ...

Looking for assistance in using JavaScript to determine the percentage of a DIV's width in pixels

Using PHP, I am generating boxes whose width is set to 100% of a container in CSS. Now, I want to determine the equivalent pixel value of that box... HTML <div class="masonry" > <? while($row = $stmt->fetch()){ ?> <div class="i ...

Tips for perfectly aligning heading both horizontally and vertically

https://i.sstatic.net/8ttSh.png https://i.sstatic.net/vSsH5.png My website has a header with text that I want to center both horizontally and vertically. I am currently using the 'text-center' class in Bootstrap 4, which centers the text but onl ...

Is it possible to connect a JavaScript file to an HTML document within a React application?

I have been developing a React website with the following file structure: public: index.html second.html src: index.js second.js table.js forms.js The main page (index.js) contains both a form and a table. One of the columns in the table has a link t ...

HTML - Lists Not Displaying Properly in Numerical Order

My goal with HTML is to: Produce 2 Numbered Lists Nest an Unordered List within Each Ordered List and add elements inside Unfortunately, my numbering isn't displaying correctly. Instead of 1. 2. etc., I'm seeing 1. 1. Below is the code I am u ...

Ways to conceal overflow at the base of a container while enabling the image to break free from the top of the container

Trying to create a visual effect where an image of a person appears to be partially hidden inside a container, with the bottom part concealed by overflow: hidden. However, I want the top part of the image to extend out of the container. Is there a way to a ...

Resolve the issue of text overlapping on an image when zooming in

There seems to be an issue with overlapping text and images when zooming the page. I have included a screenshot for reference, please take a look and provide a solution. Thank you in advance.https://i.sstatic.net/oVlGN.png Here is the CSS code causing the ...

Can we retrieve the CSS of an element?

Using Selenium's webdriverJS, I have automated tasks on an HTML5 page. To incorporate a CSS selector into a function, I had to rely on XPath for selecting elements: var complexXpath = "//*/div/a"; /* This is just an example */ var element = mydri ...

How to Fix Items Being Pushed Down by 'Particleground' Jquery Plugin Due to Z-Index and Positioning

I'm grappling with understanding z-index and positioning, despite reading various questions and articles on the topic. Currently, I'm attempting to incorporate a Jquery Plugin called 'Particleground': https://github.com/jnicol/particle ...

switch from material ui lists on/off

Trying to learn React through coding, I've encountered an issue with displaying the 'StarBorder' icon next to folders when clicked. Currently, clicking on any folder displays the 'StarBorder' icon for all folders. Any tips on how t ...

Adjust the size of the logo as the user scrolls

Currently, I am implementing a JavaScript feature that allows my logo to shrink when the user scrolls down and grow when they scroll up. To achieve this effect, I am utilizing the jQuery functions addClass and removeClass. However, I have encountered som ...

What is the best way to turn a calendar table's <td> elements into interactive form elements?

I am currently working on developing an events booking form, but I am facing a challenge. I want users to be able to click on a specific date in a table cell representing a calendar to select their start date. However, my expertise lies more in PHP progra ...

Run Javascript code if a specific CSS class is present on an element

Whenever a user enters an incorrect value into a textbox on my page, an error message is displayed within a div with the class 'validation-errors'. I'm looking for a solution to trigger a javascript function (which adds a CSS property to a ...

Creating a perfect design with Font Awesome 5 SVG icons and vertically aligned text at the top

Check out my code example on CodePen, view source. I'm looking for a way to align an icon and text vertically without using JavaScript. I want to maintain the li element's line-height and other styles. Any suggestions? ...

Is it possible for a CSS Transition/Transform to ease out smoothly yet not ease in at all?

It appears that the transition is smoother when I stop hovering over the button, compared to when I actually hover. Why might this be? .button_1 { border-width: 0.8px; border-color: Lightgray; background-color: hsla(209, 72%, 59%, 0.85); ...

The Bootstrap table fails to display any data retrieved from the server

I recently attempted to implement pagination using this resource: After setting up the HTML table on my page and confirming that the server-side code is functioning properly by checking the Network tab in the F12 tools, I ran into an issue. The data retur ...

Listening for events to wait for all XMLHttpRequest requests within an iframe

I have a basic HTML page that includes an iframe element <html> <head> $('#page-wrapper').ajaxStop(function() { console.log("Page Fully Loaded." ); }); </head> <body> <h3>Demo Page<h3> <iframe id= ...

retrieve the value of a text form using jQuery and its corresponding id

I need help with a basic HTML form that includes jQuery. My goal is to: 1) Retrieve the value into a JavaScript variable. 2) Send it as JSON to a server. Here is the form: <div data-role="main" class="ui-content"> <data=role "form" ...

The event tooltip in fullcalendar does not show up as expected

Within my Laravel 5.8 / Bootstrap v4.1.2 / jQuery jQuery v3.3.1 fullcalendar v4.3.1 application, I am attempting to incorporate tooltips for events in the fullcalendar plugin. To achieve this, I referred to a specific example provided here: Sample Example ...