diff --git a/crates/biome_html_formatter/src/html/auxiliary/self_closing_element.rs b/crates/biome_html_formatter/src/html/auxiliary/self_closing_element.rs index 5723b77ea522..7810bd475975 100644 --- a/crates/biome_html_formatter/src/html/auxiliary/self_closing_element.rs +++ b/crates/biome_html_formatter/src/html/auxiliary/self_closing_element.rs @@ -21,9 +21,15 @@ impl FormatNodeRule for FormatHtmlSelfClosingElement { space(), attributes.format(), space(), - slash_token.format(), - r_angle_token.format() ] - ) + )?; + + if slash_token.is_some() { + write!(f, [slash_token.format()])?; + } else { + write!(f, [text("/")])?; + } + + write!(f, [r_angle_token.format()]) } } diff --git a/crates/biome_html_formatter/tests/specs/html/self-closing.html b/crates/biome_html_formatter/tests/specs/html/self-closing.html index 3fc714a368c2..e52c5495725d 100644 --- a/crates/biome_html_formatter/tests/specs/html/self-closing.html +++ b/crates/biome_html_formatter/tests/specs/html/self-closing.html @@ -1 +1,4 @@ -
+
+
+ +
\ No newline at end of file diff --git a/crates/biome_html_formatter/tests/specs/html/self-closing.html.snap b/crates/biome_html_formatter/tests/specs/html/self-closing.html.snap index 0cf197454624..9f690c1cbbe2 100644 --- a/crates/biome_html_formatter/tests/specs/html/self-closing.html.snap +++ b/crates/biome_html_formatter/tests/specs/html/self-closing.html.snap @@ -5,8 +5,10 @@ info: self-closing.html # Input ```html -
- +
+
+ +
``` @@ -25,4 +27,7 @@ Attribute Position: Auto ----- ```html -
``` +
+
+ +
```