question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Trailing semicolon in inline style tags

See original GitHub issue

Prettier 2.0.2 Playground link

--parser html

Input:

<!DOCTYPE html>
<html>
  <body>
    <div style="padding: 5px">
      Hello
    </div>
  </body>
  </html>

Output:

<!DOCTYPE html>
<html>
  <body>
    <div style="padding: 5px;">
      Hello
    </div>
  </body>
</html>

Expected behavior:

I would expect a trailing semicolon not to be added to inline style tags that contain a single property.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:12 (12 by maintainers)

github_iconTop GitHub Comments

6reactions
j-f1commented, Mar 30, 2020

Although both syntaxes are valid, I agree with you that we shouldn’t put a trailing semicolon on single-line style attributes just like we don’t put trailing commas on single-line objects in JS, which is what these strings are most similar to.

1reaction
alexander-akaitcommented, Apr 11, 2020

As far as which convention is prettier, I think omitting is much cleaner looking.

Agree

Read more comments on GitHub >

github_iconTop Results From Across the Web

Inline CSS formatting best practices - Two questions
The normal rules of CSS apply inside the style attribute. Each CSS statement must be separated with a semicolon ";" and colons appear...
Read more >
Is a closing semicolon required in css and other question
A trailing semi-colon is not needed on the last rule. e.g. However, personally I only ever omit the semi colon when I use...
Read more >
declaration-block-trailing-semicolon - Stylelint
The trailing semicolon is the last semicolon in a declaration block and it is optional. This rule ignores: Less mixins; trailing // comments ......
Read more >
Inline Styles in HTML - Codecademy
Inline styles directly affect the tag they are written in, without the use of selectors. ... Don't forget to include the semicolon ;...
Read more >
How Style Sheets Work (Web Design in a Nutshell, 2nd Edition)
Inline styles. Style information can be added to an individual element by adding the style attribute within the HTML tag for that element....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found