Support self-closing elements

Allow tags to be self-closed. This is extracted from #51.