PDA

View Full Version : Html to Xhtml questions



Morgenmuffel
28-10-2010, 03:03 PM
Ok I am getting through this slowly, I don't expect the pages to validate 100% but under 40 errors a page would be an improvement

doctype

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

anyway when validating

Error One

The name attribute

I am using forms and i keep getting an error

there is no attribute "name"

on the <form> tag,

so if i name the id attribute the same as the form name it should work?
actual code is shown below in next problem


Error Two

document type does not allow element "input" here; missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div", "pre", "address", "fieldset", "ins", "del" start-tag



<div id="tps">
<div id="tps3">
<form action="/search.php" method="post" name="form1" id="form">
SEARCH
<input name="search" type="text" class="searchbox"/>
<input name="thumbnails" type="hidden" id="thumbnails" value="yes"/>
<input type="submit" name="Search" value="GO"/>
</form>
</div>
</div>

This i don't get, the Inputs are enclosed in Div tags so i shouldn't get an error

Error three

Is also caused by the above code specifically the word "Search"



character data is not allowed here
SEARCH



You have used character data somewhere it is not permitted to appear. Mistakes that can cause this error include:
putting text directly in the body of the document without wrapping it in a container element (such as a <p>aragraph</p>), or
forgetting to quote an attribute value (where characters such as "%" and "/" are common, but cannot appear without surrounding quotes), or
using XHTML-style self-closing tags (such as <meta ... />) in HTML 4.01 or earlier. To fix, remove the extra slash ('/') character. For more information about the reasons for this, see Empty elements in SGML, HTML, XML, and XHTML.


Any help appreciated as i am a touch stumped

inphinity
28-10-2010, 03:06 PM
What doctype have you declared at the top of the page?

Morgenmuffel
28-10-2010, 03:12 PM
I have just added it to the original post, i knew someone would ask

Erayd
28-10-2010, 03:24 PM
XHTML strict doesn't allow unwrapped text or <input> tags; wrap them in something and your problems will go...

It's also worth pointing out that wasting time making your page validate perfectly is somewhat pointless, unless you're in the mood for killing time - provided your code is reasonably sane, easily understood by whoever needs to maintain it next time, and renders properly in all major browsers, that's all you really need.

Note also that strict adherence to the standards will sometimes cause more problems than it solves.

Morgenmuffel
28-10-2010, 03:32 PM
XHTML strict doesn't allow unwrapped text or <input> tags; wrap them in something and your problems will go...

It's also worth pointing out that wasting time making your page validate perfectly is somewhat pointless, unless you're in the mood for killing time - provided your code is reasonably sane, easily understood by whoever needs to maintain it next time, and renders properly in all major browsers, that's all you really need.

Note also that strict adherence to the standards will sometimes cause more problems than it solves.

I do agree, however these ones are on every single page and provided its fairly simple i'd like to get rid of them, also as it will help me learn a bot about xhtml that i didn't know, and quite frankly i'd like to leave the site better than when i found it

anyway does that mean i have to wrap everysingle one of those input tags plus the text

eg somthing like



<div id="tps">
<div id="tps3">
<form action="/search.php" method="post" name="form1" id="form">
<span>SEARCH</span>
<span><input name="search" type="text" class="searchbox"/></span>
<span><input name="thumbnails" type="hidden" id="thumbnails" value="yes"/></span>
<span><input type="submit" name="Search" value="GO"/></span>
</form>
</div>
</div>

Erayd
28-10-2010, 03:46 PM
Not quite - if I recall correctly, simply sticking a single <div> inside the form but outside the inputs and text should be enough - basically anything that avoids them being direct children of the form. If I've remembered wrongly, the w3 parser should tell you what's required.

Note also that span isn't a block element (unless you take the counter-intuitive approach and style it that way); it shouldn't really be used as such unless you're intending to confuse people.

Morgenmuffel
28-10-2010, 03:57 PM
Cheers I'll try this



<div id="tps">
<form action="/search.php" method="post" name="form1" id="form">
<div id="tps3">
SEARCH
<input name="search" type="text" class="searchbox"/>
<input name="thumbnails" type="hidden" id="thumbnails" value="yes"/>
<input type="submit" name="Search" value="GO"/>
</div>
</form>
</div>