Results 1 to 7 of 7

Thread: Magic Submit Button!

  1. #1
    Join Date
    Nov 2009
    Location
    Isfahan, Iran
    Posts
    229
    Thanks
    46
    Thanked 1 Time in 1 Post

    Default Magic Submit Button!

    Hi,

    The following code seems to be valid:

    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    
    <title>Sample Form</title>
    
    <style type="text/css">
    
    input {width:500px; padding:3px; background:green; border:1px solid red;}
    
    textarea {width:500px; height:150px; padding:3px; background:green ; border:1px solid red;}
    
    </style>
    
    </head>
    <body>
    
    <form action="">
    
    <p><input id="entry_0"><label for="entry_0">Name</label></p>
    
    <p><input id="entry_1"><label for="entry_1">Email</label></p>
    
    <p><input id="entry_2"><label for="entry_2">URL</label></p>
    
    <p><textarea id="entry_3" rows="5" cols="5"></textarea></p>
    
    <p><input type="submit" value="Submit"></p>
    
    </form>
    
    </body>
    </html>
    However, the submit button width is shorter than other fields. Strangely when I remove the doctype declaration, they all get the same length. What am I doing wrong and how can I make them the same size?

    Thanks in advance!
    Rain Lover

  2. #2
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Its always better to have them separate in my opinion and don't use input use their ID or use input[type="text"] {} for the text fields and input[type="submit"] {} for the submit button

  3. #3
    Join Date
    Nov 2009
    Location
    Isfahan, Iran
    Posts
    229
    Thanks
    46
    Thanked 1 Time in 1 Post

    Default

    Quote Originally Posted by efini93 View Post
    Its always better to have them separate in my opinion and don't use input use their ID or use input[type="text"] {} for the text fields and input[type="submit"] {} for the submit button
    It doesn't make a difference.

  4. #4
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,920
    Thanks
    2
    Thanked 267 Times in 262 Posts

    Default

    Hi there Rain Lover,
    Strangely when I remove the doctype declaration, they all get the same length.
    Using "Quirks Mode" may appear to offer a solution to the problem but it is obviously not an ideal method of coding.

    In "Standards Compliance Mode", if the width or height values of the input elements - (type submit and reset) are defined,
    then border or padding values will be contained within that value.

    This means that in your example the width of the submit button needs to be 508px - (500px width + 6px padding + 2px border).

    Here is your modified example code...
    Code:
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
       "http://www.w3.org/TR/html4/strict.dtd">
    <html lang="en">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <meta name="language" content="english"> 
    <meta http-equiv="Content-Style-Type" content="text/css">
    
    <title>Sample Form</title>
    
    <style type="text/css">
    input {
       width:500px;
       padding:3px;
       border:1px solid red;
       background:green;
     }
    textarea {
       width:500px;
       height:150px;
       padding:3px; 
       border:1px solid red;
       background:green ;
     }
    #submit {
       width:508px;
     }
    </style>
    
    </head>
    <body>
    
    <form action="#">
    <p><input id="entry_0"><label for="entry_0">Name</label></p>
    <p><input id="entry_1"><label for="entry_1">Email</label></p>
    <p><input id="entry_2"><label for="entry_2">URL</label></p>
    <p><textarea id="entry_3" rows="5" cols="5"></textarea></p>
    <p><input id="submit" type="submit" value="Submit"></p>
    </form>
    
    </body>
    </html>
    
    coothead

  5. The Following User Says Thank You to coothead For This Useful Post:

    Rain Lover (12-22-2010)

  6. #5
    Join Date
    Nov 2009
    Location
    Isfahan, Iran
    Posts
    229
    Thanks
    46
    Thanked 1 Time in 1 Post

    Default

    Quote Originally Posted by coothead View Post
    In "Standards Compliance Mode", if the width or height values of the input elements - (type submit and reset) are defined,
    then border or padding values will be contained within that value.
    That's the reasonable explanation I was waiting for. Your answers are always quality!
    Thanks!

  7. #6
    Join Date
    Nov 2006
    Location
    chertsey, a small town 25 miles south west of london, england.
    Posts
    1,920
    Thanks
    2
    Thanked 267 Times in 262 Posts

    Default

    No problem, you're very welcome.

    Unfortunately I was unable to supply you with a link that might verify my assertion.
    coothead

  8. #7
    Join Date
    Dec 2010
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by Rain Lover View Post
    It doesn't make a difference.
    It probably didn't work because you kept the same width(500px) for both.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •