On save of a .html.erb file automatically adds a space to br tag

Original code

<span class="fs-5 fw-bold"> Departments (<%= @departments.count %> </span><br/>

When hit : cmd + s to save the file, the <br/> feels like it unnecessarily changes to <br /> (i.e., with unncessary added space) like below

<span class="fs-5 fw-bold"> Departments (<%= @departments.count %> </span><br />

How to prevent the unnecessary extra space in br tag from being added on file save ?

Hey, this behavior might be caused by an extension, like a formatter or an extension for ERB. Also, Cursor has a built-in formatter. According to modern HTML5 standards, a space before the / in self-closing tags is not required, but some linters and editors consider it good practice to add a space.

1 Like

Please accept my sincere apologies for a late response, few unexpected things came up for me in the last 1-2 weeks. Thank you so much for letting me know @deanrie and for clarifying this for me that it’s a good standard with some linters.