I have read that the ‘pre’ tag will collapse all white spaces and tabs into one space, but it doesn’t do so for me.
why is it so? is it depending on web browser or should I do something more?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
From HTML 4.01 Specification
PRE tags will leave white space as you have typed it. The purpose is just that. If you don’t use a pre tag, standard HTML will collapse white space as you have written. Use PRE if you are interested in preserving white space, not collapsing it.
Here is an example in JSFiddle.
This will preserve white space:
This will collapse white space: