Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Other P Element — in Code why does it Display w/o breaks but with spaces?

  • This topic is empty.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #35617
    caseyburnett
    Participant

    So I understand that the following code inside

    tag will display without the breaks BUT with spaces?

    Pellentesque habitant morbi tristique

    senectus et netus et malesuada fames

    ac turpis egestas.

    will display:

    “Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.”

    My question: WHY? The reason I ask is how do I know when a space does or does not exist between text (say that was c & p) and now seperated in code.

    For my own research — I looked at http://www.w3.org/TR/html5-author/the-p-element.html /// then here w3school /// then looked at different interpretation of w3.org here and here ///

    thanks.
    Casey

    #92594
    jamygolden
    Member

    Why would you need to know if an html line break or space exists? Is there something specific you’re having a problem with or is this just a general question?

    #92595
    Senff
    Participant

    The

    element defines a paragraph. Although spaces between words are displayed as usual, a line break within the

    element code is only displayed as a space.

    Not sure why you need to know “why”, this is standard

    behavior…..?

    #92603
    TheDoc
    Member

    When the code is rendered, white space is ignored. To actually create a line break you need to manually do it with < br >.

    #92647

    That is to do with how the white space is handled (as mentioned by @TheDoc). If you want to understand that a bit more (and control that behaviour) read this: http://www.w3.org/wiki/CSS/Properties/white-space

    And this covers browser support: https://developer.mozilla.org/en/CSS/white-space

    #94769
    caseyburnett
    Participant
Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘Other’ is closed to new topics and replies.