Results 1 to 5 of 5

Thread: wrap not valid in 4.01 strict

  1. #1
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default wrap not valid in 4.01 strict

    I am trying to validate a page using doctype

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

    when I get the error that wrap is not recognized. I am also not using cols attribute either since the width is fluid. In order to get this to validate should I be using a different doctype or a css equivalent for wrap and the cols attribute?
    Last edited by james438; 05-31-2011 at 05:16 AM.
    To choose the lesser of two evils is still to choose evil. My personal site

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    I take it this is as regards the textarea tag. If so, there's no good substitute for wrap. The closest css equivalent is (for wrap="off"):

    Code:
    white-space: nowrap;
    However, perhaps until recently (I haven't checked this in the most recent browsers yet, I'm assuming that most of them now comply) not all the browsers see it that way. The older versions still abound though. In a couple of years maybe.

    I don't think there are other types of wrap that one would need to be concerned about. The two others are hard/physical, and soft/virtual. These determine how the text is transmitted to the server. I'm unaware of any css equivalents for them. As they don't affect what the user sees, there probably aren't any. I believe the default is soft/virtual in most browsers. That means that unless the user hits the enter key while typing, no line break is sent when the data is submitted, but the text in the textarea will wrap visually to accommodate its dimensions. With hard/physical wrapping, the text wraps to accommodate the dimensions, and when sent to the server retains the line breaks as seen by the user in the textarea.

    As for a DOCTYPE that would support wrap? I don't think any of the standards invoking DOCTYPES do.

    This is one of those few cases where somethings just fall through the cracks.

    However, as far as I know, wrap still works just fine. So you're left with the option of either using it and having that one glitch in your validation, or resorting to various workarounds. I'm thinking of wrap="off" here. But it would work with the other two kinds. You can have the textarea be written using javascript. If done - say with a document.write like so:

    Code:
    <script type="text/javascript">
    /* <![CDATA[ */
    document.write('Result: <textarea id="strNote" cols="50" rows="1" wrap="off" readonly><\/textarea><br>');
    /* ]]> */
    </script>
    That will validate to HTML 4.01 strict.

    Depending upon the objective one could substitute other elements and style them as I did for the code blocks on this page:

    http://home.comcast.net/~jscheuer1/side/thecrawl/

    They look like textareas, but they're not.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    Thanks for explaining. I will leave my code as is then and leave the wrap="off" attribute in.

    I notice that HTML5 does allow for the wrap attribute however ref. I will probably start using it soon when HTML5 becomes more commonplace.
    To choose the lesser of two evils is still to choose evil. My personal site

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Yes but . . . in HTML 5 wrap="off" is still invalid. Only 'hard' and 'soft' are allowed.

    It's my opinion that the people who make the standards just have very little sympathy for presentational attributes.

    Oh, and I just did a quick test in the latest release versions of various browsers (Firefox, IE, Opera, Chrome, Safari). Only Firefox appears to not respect:

    Code:
    textarea {
    	white-space: nowrap;
    }
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    If wrap is the only error then it still seems like the best option is to leave things the way they are.

    I sort of wish that Firefox put a bit more effort on recognizing the w3c standards. I am not as concerned with their browser specific css.
    To choose the lesser of two evils is still to choose evil. My personal site

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
  •