CSS direct in HTML tag [closed]

0

I bring a question today regarding CSS

Sometimes it's more feasible to put the direct CSS code in the HTML tag and wonder if this is a bad practice

How do I proceed with this question? It is really bad? I make the time and then I move to an external sheet?

Thank you

    
asked by anonymous 19.10.2016 / 02:58

3 answers

2

This is relative to the amount of code you are going to enter, if you have a CSS that takes care of the whole page design it is best to leave it whole in a minified file and load it into your pages. But suppose in a specific page you do not want to use the entire file, and you want only some class or some specific ID of that CSS, in that case it is better for the perfomance of your site to insert these classes and Ids directly into the HTML. p>     

19.10.2016 / 03:05
2

I would say that the ideal is to avoid when possible. Such "good practice" is like in other tools: we do not use the hammer to cut or the pliers to hit nail. For this we have the style sheet, maintaining the organization.

But as they have said, inline, depending on the case, can be useful and even inevitable. It is worth remembering that it takes precedence over leaf styles (except those! Important). It may be the last resort, even if not ideal, for a problematic design, and then I use it all the time.

    
19.10.2016 / 22:09
1

Depends, if the style you are going to assign can be reused somehow by another component, ideally you separate it into another file, but if you have intentionally want that style to be used only for that particular component or only for a specific page, in this case the ideal is to put the style only on the page or even directly in the component.

    
19.10.2016 / 18:51