Grow your CSS skills. Land your dream job.

pre tag

  • # August 2, 2012 at 12:35 am

    There is a table inside a paragraph. The cell inside the table has extra new line. Below is relevant part of the code.

    < !DOCTYPE html>











    11111



    Now when I remove the pre tag from outer most para, the new lines is not seen. Any ideas why this is happening?

    thanks
    ns.

    # August 2, 2012 at 12:53 am

    I would suggest running that through a validator, as there are quite a few problems with that, the biggest of which is wrapping a bunch of block level element with a paragraph. Here is a good validator: http://validator.w3.org/check

    # August 2, 2012 at 1:03 am

    Thanks. I will do it.

    # August 2, 2012 at 1:19 am

    I have total-validator installed as a plugin in firefox. I validated with that and changed the HTML. instead of pre tag, I used “white-space: pre” as a style for para and it looked good. Thank for the tip @joshuanhibbert.

    I have a question:
    when i give a new line after the para tag, the browser adds small amount of horizontal space after the text (may be couple of pixels):


    11111

    But when I give this way:

    11111

    There is no space after the text. Does HTML code spacing(new line) also has effect on how the HTML will look in the browsers?

    # August 2, 2012 at 1:39 am

    It does if you are rendering elements as inline, but shouldn’t if you are rendering them as block level.

    # August 2, 2012 at 1:46 am

    What do you mean by this? Should I use paragraphs as inline ?

    # August 2, 2012 at 2:22 am

    Paragraphs are block level by default, and therefore shouldn’t render white space. If they are, then there must be some overriding styles somewhere causing that.

    # August 2, 2012 at 4:57 am

    ok. Thanks for your help.

    # August 2, 2012 at 7:55 am

    No worries.

Viewing 9 posts - 1 through 9 (of 9 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".