开发者

Need help making form W3C compliant

I've styled a domain search form with CSS and DIV tags, but it's not W3C compliant since I separated the form tags. How can I get around this and still be able to style each compone开发者_运维问答nt of the form?

<div class="reg-domain-txt">
<span>Register Your Domain Name Today!</span>
</div>


<div class="checkerform">
<form action="https://www.xhostcompanyx.com/clients/domainchecker.php" method="post">
<input type="hidden" name="token" value="xxxxxxxxx" /> 
<input type="hidden" name="direct" value="true" /> 
<input class="inputbox" type="text" name="domain" size="29" />
</div>

<div class="tldboxlist">
<select class="tldbox" name="ext">
<option>.com</option>
<option>.net</option>
<option>.org</option>
<option>.biz</option>
<option>.us</option>
<option>.info</option>
<option>.mobi</option>
<option>.me</option>
<option>.co</option>
<option>.tv</option>
<option>.pro</option>
</select>
</div>


<div class="domaincheckbutton">
<input class="domainbutton" type="submit" value="Search" />
</form>
</div>


Just put the start and end form tags outside of the divs.

Please explain why this will prevent you from styling?


The code you’ve posted isn’t valid because you’ve opened a <div> tag, then opened a <form> tag, then closed the <div> tag before closing the <form> tag. You can’t do that with any tags in HTML.

Here’s your HTML, corrected and indented — indentation really helps make these kinds of HTML errors more obvious:

<div class="reg-domain-txt">
    <span>Register Your Domain Name Today!</span>
</div>


<div class="checkerform">
    <form action="https://www.xhostcompanyx.com/clients/domainchecker.php" method="post">
        <input type="hidden" name="token" value="xxxxxxxxx" /> 
        <input type="hidden" name="direct" value="true" /> 
        <input class="inputbox" type="text" name="domain" size="29" />

        <div class="tldboxlist">
            <select class="tldbox" name="ext">
                <option>.com</option>
                <option>.net</option>
                <option>.org</option>
                <option>.biz</option>
                <option>.us</option>
                <option>.info</option>
                <option>.mobi</option>
                <option>.me</option>
                <option>.co</option>
                <option>.tv</option>
                <option>.pro</option>
            </select>
        </div>


        <div class="domaincheckbutton">
            <input class="domainbutton" type="submit" value="Search" />
        </div>
    </form>
</div>


I would remove the three DIVs. They are not necessary for content or styling. If you need to group together form elements, you should use the FIELDSET tag. Also, if you need to position the entire form, you can give the form an ID or a Class.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜