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?
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.
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.
That is right, but the container of your paragraphs must have a fixed width, or you're back to square one.
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).
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 */ }