'How to resolve the following HTML error?
I have the following lines in my django template file:-cart.html:-
<td class="right">
<form method="post" action="." class="cart">
<label for="quantity">Quantity:</label>
<input type="text" name="quantity" value="{{ item.quantity }}" id="quantity" size="2" class="quantity" maxlength="5" />
<input type="hidden" name="item_id" value="{{ item.id }}" />
</td>
<td>
<input type="submit" name="submit" value="Update" />
</form>
</td>
At the first closing tag of td i.e is the first </td>,i get the following error:
Element form is not closed.Please help me to rectify this error.
Solution 1:[1]
Well, try tabbing the first line so that it is lined up with its closing tag.
Then I'd fiddle with the code for bit and try out things. Here's a good article to look at: http://help.simplytestable.com/errors/html-validation/end-tag-for-element-x-which-is-not-open/end-tag-for-element-form-which-is-not-open/
Solution 2:[2]
If you are trying to put the form across multiple tds, that will be difficult with your current approach.
Unfortunately, you can't have the form inside a table row, and your current HTML is invalid since the td element is closed before the form element.
You either need to:
- have the whole table in the form
- Have the whole form in a table cell.
- Use the html5 form attribute
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Darcey Mckelvey |
| Solution 2 | Community |
