Sam Simith
Sam Simith

Reputation: 51

HTML code indentation issues in google chrome browser

click this links to see the screenshots

I have been keeping the code indentation in that web pages from the beginning in my code editor. but when i see my site on google chrome, the indentation is not set properly. can I know why is this? I googled this, yet coudn't find an answer or a solution.

Upvotes: 1

Views: 1286

Answers (1)

Radek
Radek

Reputation: 846

It is not Google Chrome's fault. Your files simply get compiled to this form, the browser displays them exactly as they look like.

But why they look like this? In your case PHP's include does only purely textual replacement, as in the picture bellow: enter image description here

The effect is the same as if you copied the contents of the external file and pasted them to the main file, replacing the include tag.

If you would really insist on having the code indented properly after the include does its job, you would have to add new spaces at the beginning of each line (but first) of the included file. It would shift the text to the right (in this case 4 spaces) and in the result the indentation would be preserved.

However, I'd discourage you from doing so -- it is only the code that is generated, probably no one is going to work with the compiled result. Proper formatting of code is only meant to make the human work easier -- it has no effect on how the page will eventually look like, when rendered by browser. Thus, it probably would suffice if you kept the two source files formatted as they currently are and left the output as is, even though it is not indented well.

If you'd like to have the code properly formatted in the page source view, please remember that you can simply use the "pretty print" button in the lower left corner of the preview:enter image description here

Upvotes: 1

Related Questions