Search code examples
htmlcssinline-code

Is it bad practice to use inline styles?


Is it bad practice to occasionally put some CSS directly into some HTML tags if I am sure that it won't be used again?

For instance:

<div style="padding-left: 0"></div>

Or do I have to systematically create new class even for little tweaks that will pollute my CSS file?


Solution

  • Yes it is fine. Stylesheets are used mostly to style multiple pages in the same manner and for easier editing. Putting css directly in html also overrides all other conflicting styles.