473,387 Members | 1,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

input tags in forms and xHTML...

Hi All,

I have a question regarding the use of the input tag in forms when using xHTML 1.1 strict.

Basically I'm getting errors suggesting the input tag is not allowed inside the form e.g: document type does not allow element "input" here; missing one of "ins", "del", "h1", "h2", "h3", "h4", "h5", "h6", "p", "div", "address", "fieldset" start-tag.

I've heard mention of the input tag not existing in xHTML strict, but I'm a) not sure if that is true and b) am not aware of an alternative.

The code in question is shown below:
[HTML]<div class="siteproject">
<p class="h8">Iris</p>
<p><a href="img/iris.html" class="projectlink">click to enlarge</a></p>
<p><a href="img/iris.html" class="projectimg"><img src="img/jpg/irissmall.jpg" alt="iris image" class="projimg"/></a></p>
<!-- START CART CODE -->
<p>Iris - &pound;28.95</p>
<form action="http://www.romancart.com/cart.asp" method="post">
<input type="hidden" name="storeid" value="12345"/>
<input type="hidden" name="price" value="28.95"/>
<input type="hidden" name="quantity" value="1"/>
<input type="hidden" name="itemname" value="Iris Kit"/>
<input type="submit" value="Add to Basket"/>
</form>
<!-- END CART CODE -->
</div>[/HTML]

I cannot see any particular reason why this would not be correct code, except for perhaps my css div declaration implying an inline element, so maybe the validator see's it as a <p> or equivilent and doesn't like the form or input tags being inside it.

Can anyone shed any light on this? It's bugging me now!
Mar 11 '07 #1
6 4229
drhowarddrfine
7,435 Expert 4TB
You have the form inside the <p> but it is the <input> elements that must be inside a <p> or <div>.
Mar 11 '07 #2
I don't think the form is inside a <p> but I will try enclosing the inputs inside this and see if it validates, thanks for the advice
Mar 11 '07 #3
drhowarddrfine
7,435 Expert 4TB
Yes, you are right. I saw the <p> in front of Iris but not the closing </p> at the end of the line. But the inputs do need to be inside a <p> or <div> or other elements.

btw, you should not be using xhtml 1.1. v1.1 is pure xml and intended to be served as such. You are probably serving it as text/html.
Mar 11 '07 #4
Thanks for the tip, the page will validate fine with the inputs surrounded in <p>'s

I think originally i misinterpreted the advice from someone to include the inputs in a <div>. I assumed one div around the lot what suffice, but obviously not!

Thanks again,

Doug
Mar 11 '07 #5
Interesting comment about the usage of xHTML 1.1, I simply assumed it was wise to code the html to the latest spec. I am using the following doc type:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

Are you saying that really that should only be used for straight XML? if so, can you suggest a better alternative?

I am a little reluctant to change as I do like the way it parses certain elements.
Mar 11 '07 #6
drhowarddrfine
7,435 Expert 4TB
From the W3C:
Why is it disallowed to send XHTML 1.1 documents as text/html?

XHTML 1.1 is pure XML, and only intended to be XML. It cannot reliably be sent to legacy browsers. Therefore XHTML 1.1 documents must be sent with an XML-related media type, such as application/xhtml+xml.
In addition, if you serve the page as text/html then the browser will interpret it as html and throw everything else out.
Mar 11 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

13
by: clod | last post by:
for example if I have a box where you should put a date how do I keep today date inside that box as default?
4
by: Luke Dalessandro | last post by:
I have some XML data that has mixed content XML tags that embed XHTML tags, for instance: <note>Somebody wrote this note in XHTML and wanto to <a href="link.html" target="_new">link</a> to a...
8
by: Hostile17 | last post by:
Consider the following HTML. ---------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd"> <html> <head> <meta...
4
by: Martin Lucas-Smith | last post by:
I am wanting to know whether are XHTML1-valid characters for use within an id attribute and/or a name attribute. ...
30
by: Toni Mcintyre | last post by:
i'm having 2 problems with the http://validator.w3.org 1. if i have: <meta http-equiv="Content-Script-Type" content="text/javascript"> then why do i need <script type=text/javascript>...
12
by: Randell D. | last post by:
Folks, I have a form called "ourTestForm". Its a test form - nothing special - it contains five input tags - they are named one, two, three, four and five. The input tags are of type...
3
by: Jonathan | last post by:
Hi all: I originally posted this in an HTML forum, but have realized that the solution may (a) require a server-side change or (b) be non-existent. In any case, since the page I'm dealing with is...
11
by: C.W.Holeman II | last post by:
I what to hide an input element and the following text. I have the selector for the input working and just need to grab the text following it. CSS: form{ display:table; text-align:center; }
8
omerbutt
by: omerbutt | last post by:
hi there i have a form with multiple input (type/text ) fields and three inputs(type/file) fields i have to submit the form via ajax because i have multiple forms on this page ,you can say it is a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.