Using <br /> between text

Discussion in 'HTML & Website Design' started by virtualmisc, Oct 5, 2009.

  1. #1
    My friend asked me to convert a doc file he sent me into html.
    He said he wanted it to look exactly like the doc.
    So I put <br /> in between the lines so the text appears like the one in doc.
    But he says now the text looks weird.
    Is it because I used <br />?
    Is text wrapping automatically done?
     
    virtualmisc, Oct 5, 2009 IP
  2. aap

    aap Well-Known Member

    Messages:
    1,802
    Likes Received:
    39
    Best Answers:
    2
    Trophy Points:
    120
    #2
    <br /> is used to break line.

    Instead use

    <div>text.... </div>
    
    Code (markup):
     
    aap, Oct 5, 2009 IP
  3. Typo Tat

    Typo Tat Peon

    Messages:
    115
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Depends on the width of his screen, if it's smaller than the width of your full line, then yes, the line will wrap automatically.

    You can prevent that by giving a fixed width to the element that holds your text. Then, if the screen is too small, there'll be horizontal scrollbar, but the text wont wrap. And, of course, make sure you specify the font of your text, because if you don't, you can never be sure how it'll look on different computers.
     
    Typo Tat, Oct 5, 2009 IP
  4. forextrendalerts

    forextrendalerts Guest

    Messages:
    132
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I used <br /> for line breaking....in HTML
     
    forextrendalerts, Oct 5, 2009 IP
  5. MhW

    MhW Active Member

    Messages:
    370
    Likes Received:
    23
    Best Answers:
    0
    Trophy Points:
    85
    #5
    Ideally for spacing out content you should use <p> and define your own margins / padding in the stylesheet. Every browser displays the <br /> tag differently, which is probably why your friend says it "looks weird".

    At least by using <p> and choosing your own margins and padding, you know what you're getting - and more importantly will be consistent across all browsers. :)
     
    MhW, Oct 6, 2009 IP
    Stomme poes likes this.
  6. Typo Tat

    Typo Tat Peon

    Messages:
    115
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    That is right, but the container of your paragraphs must have a fixed width, or you're back to square one.
     
    Typo Tat, Oct 6, 2009 IP
  7. Stomme poes

    Stomme poes Peon

    Messages:
    3,195
    Likes Received:
    136
    Best Answers:
    0
    Trophy Points:
    0
    #7
    That right there was silly as hell. Web pages, unlike documents, are strongly affected by the user's
    -screen resolution
    -screen size
    -available fonts
    -windowing system
    -browser settings

    The print world is very different from the web world.

    Even if you set a width or minimum width on the box containing the text (as Typo Tat suggested) and proper use of <p>'s and margins (as MhW suggested) are all nice and find and Good Things you Should Be Doing Anyway (<br> is really made for when a break in a line is necessary for content reasons, like poetry and postal addresses, not spacing between lines), but if you've got the wrong charset or your friend's got different fonts available between his browser and doc reader or between your machine's fonts and his fonts, you two will be seeing two different things.

    We are also all assuming you are talking about weirdness in spacing between text, but you didn't say that. What does your friend mean by "weird"? Possibly he is seeing improper characters like 激光%C3%86шетеÓßÔÒõ ²Å???

    Most likely to occur if he sent you text written in a Windows program still set to the default 1251 which is a goofy win-only version of latin-1 (the basic ascii chars are the same but Windows uses weird whitespace and control characters for things like "smart quotes", bleh).
     
    Stomme poes, Oct 6, 2009 IP
  8. calviin

    calviin Peon

    Messages:
    17
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    text will be wrapped automatically if you set a fixed width to your content container.
    <br /> is not a problem and will be useful if you want to break your paragraph manually

    The best format for it is

    <div class="container">
    <p>This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. This is a long text. </p>

    <p>This is a short text. This is a short text. This is a short text. This is a short text. This is a short text. This is a short text. </p>
    <p>I'll break this text into <br />two lines</p>
    </div

    with CSS

    .container {
    width: 500px; /* for example */
    }
    .container p {
    font-size: 1em; /* Adjust it to your needs */
    line-height: 1.4em; /* Adjust it to your needs */
    margin: 0 0 1em; /* Adjust it to your needs */
    }
     
    calviin, Oct 6, 2009 IP