Previous task
Text markup with HTML10/10
Back to the list of tasks
  1. 1. Paragraphs
  2. 2. Headings and subheadings
  3. 3. Unordered list
  4. 4. Ordered list
  5. 5. Multilevel list
  6. 6. Description List
  7. 7. Strong and b tags
  8. 8. Em and i tags
  9. 9. Line breaks and separators
  10. 10. Preformatted text
Task list
  • Courses
  • Sign up
  • Log in

Loading...
It will be ready in a few seconds.

  • Theory
  • Theory

Preformatted text

You've probably already noticed how different the display of code in an HTML editor and in a mini-browser is.

You can put as many spaces as you want in HTML code, but the browser will display them as one. You can also put as many line breaks as you want in HTML code, but the browser will not show them unless you use special tags like <p> or <br>.

You can change this browser behavior by using the <pre> tag, which stands for "preformatted text". The browser saves and displays all spaces and hyphens that are inside the <pre> tag.

This tag is most often used when displaying code samples.

  • index.html
HTML
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>Preformatted text</title> </head> <body> .----------------. .----------------. .----------------. | .--------------. || .--------------. || .--------------. | | | _____ _____ | || | _________ | || | ______ | | | ||_ _||_ _|| || | |_ ___ | | || | |_ _ \ | | | | | | /\ | | | || | | |_ \_| | || | | |_) | | | | | | |/ \| | | || | | _| _ | || | | __'. | | | | | /\ | | || | _| |___/ | | || | _| |__) | | | | | |__/ \__| | || | |_________| | || | |_______/ | | | | | || | | || | | | | '--------------' || '--------------' || '--------------' | '----------------' '----------------' '----------------' </body> </html>

The code has changed, click "Update" or enable autorun.

You have moved to another page

Click inside the mini-browser to highlight this window.

100%
GoalsCompleted
0
    1. Wrap all text inside the <body> tag in the <pre> tag.

    © 2023-2024, codehero.pro