I'm trying to display code but everything is showed in one line. How can I display multiline code tag?
This is my code:
index.html
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> </head> <title>Documentación: Events</title> <body> <code> { "id_tabla":3, "fecha":"02-09-2015", "privacidad":0, "timediff_m": "00" } </code> </body>
And this is how is showed in browser:
{"id_tabla":3,"fecha":"02-09-2015","privacidad":0,"timediff_m": "00"}
I can only use <code>
tag
The <br> tag is a simple and easy way to add line breaks to your HTML code. By adding the <br> tag wherever you want a line break to appear, you can make your code more readable and easier to understand.
Definition and Usage The \n character matches newline characters.
html put newline in text with \n.
HTML Line Breaks The HTML <br> element defines a line break.
This has already been answered here:
code { display: block; white-space: pre-wrap }
<code> { "id_tabla":3, "fecha":"02-09-2015", "privacidad":0, "timediff_m": "00" } </code>
Use <pre>
instead of <code>
.
<pre> { "id_tabla": 3, "fecha": "02-09-2015", "privacidad": 0, "timediff_m": "00" } </pre>
You should use <code>
if you want to have something inline and <pre>
when you need something multiline.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With