View Full Version : <form> spacing removal?
BoR|S
04-23-2003, 01:28 PM
When I use forms (<form>...</form>) there is always a line break above and under the form.
How can I remove this line break?
EDIT: When I try to validate the page for valid xhtml (http://validator.w3.org/check?uri=http%3A%2F%2Fboris.8bit.co.uk) I get errors, and I can't really understand what is wrong... :(
Coreyp_1
04-24-2003, 01:01 AM
Boris,
The CSS default for the <form> tag is "display: block", which is what puts the line break before and after the form.
You need to re-define this as "display: inline".
Good Luck!
Coreyp_1
04-24-2003, 01:08 AM
Boris,
I just looked at the validation error.
It appears that you have (accidentally) closed the <input> tags with "/>" rather than ">".
In other words, line 34 is:
<input type="hidden" name="cmd" value="_xclick" />
but it should be
<input type="hidden" name="cmd" value="_xclick" >
Have fun!
BoR|S
04-24-2003, 06:48 AM
In fact when I changed that, I got much more validations errors...
this:
http://validator.w3.org/check?uri=http://boris.8bit.co.uk/index.html
or this:
http://validator.w3.org/check?uri=http://boris.8bit.co.uk/index2.html
Coreyp_1
04-24-2003, 09:23 AM
Boris,
Here's a few ideas:
First of all, XML requires that all tags have a corresponding closing tag, so follow the <input> with </input>. That should take care of three of the errors (#2, #5, and #8).
Secondly, it seems as though XML also does not like for any text to exist outside of some sort of wrapper. Normally, this would apply to the body text having something like:
<body>
Hello, World!
</body>
XML wants it to look like this:
<body>
<div>
Hello, World!
</div>
</body>
Actually, you can wrap the text in any of a number of tags ("p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre", "address", "fieldset", "ins", or "del"), just so long as there is no text left to itself.
That being said, you probably (for some odd reason) must do the same thing in your <form></form> tags. Try placing a generic <div> inside the <form> tags, around the <input> tags. That should fix errors 1, 4, and 7.
You'll have to fill in your own code, but it'll look something like this:
<form>
<div>
<input></input>
<input></input>
<input></input>
</div>
</form>
Errors 3, 6, and 9 are just telling you where it found the other errors, and should disappear when you fix the other two things.
Hope that takes care of it!
DCElliott
04-24-2003, 09:34 AM
Corey
I am afraid you are wrong. <input . . . /> is the proper form for xhtml. Self-closing tags do not get a </close> in xhtml - you wouldn't do <img . . . > </img> or <hr></hr> - this is a common mistake.
Try wrapping each input as follows <p><input . . . /></p> so that it is enclosed within a block level element.
I'll keep checking this thread.
DE
BoR|S
04-24-2003, 09:40 AM
Thanks! Now it validates...
Anyway, I didn't know that I should use </input>... I thought that I just use <input.... /> as with <img> and <br> tags for example...
Coreyp_1
04-24-2003, 09:56 AM
DE,
No prob if I'm wrong. Just don't tell my family. I've got them convinced I know what I'm talking about! :D
In all seriousness, I'm not well-versed in XML, but the documentation on closing tags (http://www.w3.org/TR/xhtml1/#h-4.3) state that they are required for all non-empty elements.
http://www.w3.org/TR/xhtml1/#h-4.6 lists the empty elements as <br> and <hr>. <input> is not listed as being empty, so I can only assume that it non-empty, and therefore must have a closing tag (that's what the validation error was in the first place).
While "/>" is provided as a valid way of closing empty elements, again, <input> is not listed as being one of the empty elements, so I can only assume that <input /> is not a valid way to close the <input> tag.
My assumptions can be wrong, but that's what I gathered from the documentation. (And I swore I would never read the instructions!)
Who knows?
EDIT: I clarified what I was calling empty and non-empty.
BoR|S
04-24-2003, 10:01 AM
It seems anyway that using </input> passes the validation engine...
Coreyp_1
04-24-2003, 10:02 AM
OK, http://www.w3.org/TR/xhtml1/#C_2 also lists <img> as an empty element.
Congrats, Boris, on reaching validation.
DCElliott
04-24-2003, 11:57 AM
Here is one reference from an XHTML site on using input:
http://www.devguru.com/Technologies/xhtml/quickref/xhtml_input.html
DE
BoR|S
04-24-2003, 12:23 PM
Originally posted by DCElliott
Here is one reference from an XHTML site on using input:
http://www.devguru.com/Technologies/xhtml/quickref/xhtml_input.html
DE
I found this very page yesterday while trying to validate my page, however the code provided there won't validate as xhtml 1.0 strict.
DCElliott
04-24-2003, 04:01 PM
Makes me wonder if the validator is wrong or some other possibility. Did you leave a space between the last attribute and the closing slash? <input attribute="something"/> (wrong) vs <input attribute="something" /> (note the space)
Actually, in XML empty tags have to be closed and it can be done either as <emptytag></emptytag> or <emptytag />. The latter form was required so that the tags would be compatable with older browsers. I read some WDG and W3C stuff on validator problems - it will make your head ache - and am convinced that if it wants the </input> tag, then it can damn well have it. Forms are funny anyway. If you have <input> it is a single tag but if you have a <textarea>it is a paired tag</textarea> so I guess the best thing would be to treat all form elements as if they have to be paired.
DE
BoR|S
04-25-2003, 01:19 AM
I left a space...
<input type="hidden" name="cmd" value="_xclick" />
And I got errors...
Then I removed the / as Coreyp_1 suggested me to do at the top of this thread
<input type="hidden" name="cmd" value="_xclick" >
And I still got errors, even more than in the first try...
BTW, there is a similar discussion to this found here (http://www.webmasterworld.com/forum21/4826.htm).
Also the reference in w3schools (http://www.w3schools.com/tags/tag_input.asp) dealing with <input> tag in HTML and XHTML tell me to close input by <input... />.
vBulletin® v3.7.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.