How to format html files in Eclipse?

user308808 picture user308808 · Feb 6, 2011 · Viewed 67.6k times · Source

The XML formatting works perfect but not the html formatting. In fact if I use "cmd-shift-F" for a html file, it just left aligns almost everything. I've attached the before and after pictures.

No eclipse html formatting applied

After eclipse html formatting applied

Does anyone know how to fix this? I played around with HTML formatting preferences but had no luck. Note that the same document, if it is saved as xml will format perfectly.

I am using eclipse 3.6 with WTP plugin.

Answer

prasad vsv picture prasad vsv · Jan 7, 2015

go to Window --> preferences --> Web --> HTML files --> Editor.

In the Inline Elements section, select all the elements that you don't want eclipse to inline(continue with same line).

Click Apply and then Ok. Now re format using ctrl + shift + f.