0

I need to embed a huge text file in plain text which contains a lot of information organized by newlines, tabulations and spaces. This text file does not have any html tags, it's just plain text.

I need to show it embedded into an HTML file, because I don't want to write thousands of tags (<br>, etc...) to reorganize the text, because if I just paste the plain text into a <b> tag into an HTML file, the text is shown as a only paragraph without newlines, spaces and tabulations. I'm not sure how to do this. I can't find any info about that.

halfer
  • 19,824
  • 17
  • 99
  • 186
NullPointerException
  • 36,107
  • 79
  • 222
  • 382

2 Answers2

3

Contents in a <pre> tag will make use of new lines, white space, and tabs.

If you need the letters to line up on top of each other like in a command line, you're wanting a "fixed width" font. You can take a look a the <tt> tag, or you'd have to set the font for that block to a fixed-width font (which would be a different question)

efreed
  • 991
  • 11
  • 18
  • i'm testing it. I have a problem with
    , huge lines does not fit into the 100% of the width of the screen, they are taking a lot of width with horizontal scroll. How can this be avoided?
    – NullPointerException Feb 16 '16 at 23:03
  • 1
    @NullPointerException `white-space: pre-wrap;` should do that for you if you can support CSS 3. Otherwise, here are some other ways to do it: http://stackoverflow.com/a/248013/854246 – Joseph Marikle Feb 16 '16 at 23:04
  • i need to support old navigators, no css3. Which way whould work without css3? – NullPointerException Feb 16 '16 at 23:06
  • What specifically do you need to support? (and "everything" is not a realistic expectation) – Joseph Marikle Feb 16 '16 at 23:08
  • well, this website is dedicated for people with high ages, so they are commonly using Windows XP and internet explorer 6.... i think best option whould be accepted answer in the link you provided me. What do you think? – NullPointerException Feb 16 '16 at 23:21
0

The HTML spec requires a block level (or in the case of <br>, an artificially line-breaking) tag to break lines. It specifically ignores line breaks and white space in the source, so if you want your raw text to keep its line breaks, find or write a script that converts the \n character to something that causes line breaks.

Chuck Dries
  • 1,630
  • 13
  • 19