My tool of choice for editing many kinds of files including HTML is gedit. It is a clean and easy to use tool. I often have to work with old html websites. The HTML is often quite a mess with missing closing tags or just plain poorly written. I’ve also used this to fix code I was attempting to insert into site editors using the XHTML standard.
Gedit has many plug-ins. One of my favorites is HTML-Tidy. This is a link to the author’s site. Take a look and see if it helps your coding.