Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8

Thread: Strict DTD

  1. #1
    New to the CF scene
    Join Date
    Apr 2011
    Posts
    7
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Strict DTD

    Code:
    <table width="70%" align="center" id="Table1">
    <tr><td><img src = "nwlogo.jpg" width="120" height="60" alt=""/></td>
        <td><h3>Student Information</h3></td></tr>
    </table>
    <form id ="frmStudentInfo" action="ignore">
    <table align="center">

    I am attempting to use XHTML Strict DTD and was wondering if anyone knew what could be used instead of the align="center" for the image and then for the table align because it is not allowed under Strict.

  • #2
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    One option
    Code:
    <!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>
            <meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
            <title></title>
            <style type="text/css">
                #Table1 {
                    margin: 0px auto 0px auto;
                }
                #imgCell {
                    width: 120px;
                    margin: 0px auto 0px auto;
                }
            </style>
            <script type="text/javascript"></script>
        </head>
        <body>
            <table width="70%"  id="Table1" border="1">
                <tr>
                    <td>
                        <div id="imgCell"><img src = "pic1.jpg" width="120" height="60" alt=""/></div>
                    </td>
                    <td><h3>Student Information</h3></td>
                </tr>
            </table>
        </body>
    </html>

  • Users who have thanked bullant for this post:

    skylis (04-14-2011)

  • #3
    Regular Coder
    Join Date
    Jul 2002
    Location
    Kansas, USA
    Posts
    487
    Thanks
    0
    Thanked 54 Times in 53 Posts
    Another option (replace this style rule in Bullant's code):

    Code:
                #imgCell {
                    text-align: center;
                }

  • #4
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    Yes that is another option and it works but imo it is not semantically correct because the image is not text.

    It's a bit like putting a table in a div and applying text-align: center to the div to center the table. Although it will center the table, imo it's not semantically correct because the table is not text either.

  • Users who have thanked bullant for this post:

    skylis (04-14-2011)

  • #5
    New to the CF scene
    Join Date
    Apr 2011
    Posts
    7
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Thanks Bullant for your help so far. I have managed to work it down to 1 error before passing Strict DTD. I know that "name" is no longer used and I read that "id" can be put in it's place but when I do that the form stops working. Any idea what I could use in the place of "name"?

    Code:
    <form name ="frmStudentInfo" action="ignore">

  • #6
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    Quote Originally Posted by skylis View Post
    I know that "name" is no longer used and I read that "id" can be put in it's place but when I do that the form stops working. Any idea what I could use in the place of "name"?

    Code:
    <form name ="frmStudentInfo" action="ignore">
    Yes, form names are not allowed in xhtml. They are in html afaik.

    I normally code in xhtml strict as well.

    All you need to do is change the way you reference a form in your javascript. You have 2 options afaik.

    1) give the form an id

    Code:
    <form id="frmStudentInfo" action="">
    
    <script type="text/javascript">
    
         oForm = document.getElementById('frmStudentInfo');
    
    </script>
    2) use the "default" DOM form reference. All forms on a web page are stored in an array called forms in the DOM. The first form will be in forms[0], a second form will be in forms[1] etc.

    So to get the entered text in a textbox with a name="txtUsername" you could do

    Code:
    var username = document.forms[0].txtUsername.value;
    or another option

    Code:
    oForm = document.forms[0];
    var username = oForm.txtUsername.value;

  • Users who have thanked bullant for this post:

    skylis (04-14-2011)

  • #7
    New to the CF scene
    Join Date
    Apr 2011
    Posts
    7
    Thanks
    6
    Thanked 0 Times in 0 Posts
    Works perfectly. Thank you very much for your help. Still getting used to the Strict DTD so it has taken a while for me to catch onto all of it.

  • #8
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    no problem


  •  

    Posting Permissions

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