-1

I have a widget in plugin that will display a list of items <li> and I'd like to add one color to those items as option (color picker)...

The question here, do I throw that color as a:

 <style>.color {color:#fff;}</style> 

Or add it inline to each item:

<li style="color#fff;"></li>

How would you do that if this is your plugin? I'm talking about performance/Google score here.

Thanks...

0

I would personally go for using a class to apply colour rather than an inline stylesheet. This way if you need to change the colour being applied to the list element then you can just that once in the class and every list element will show the correct colour, otherwise you need to go through and change every inline style on the list elements.

I'm not sure how much difference between those two methods it would make from a performance / Google site speed score really, it depends on what level of detail you were examining performance. The class will certainly make it quicker to edit so that method would be the one I would go for.

Hope that helps!

  • Thx, however a class is not something I can use here, the color will be selected by the user... And for performance, I meant w3c validation as it seems it doesn't like when using inline <style> tags... I'll go with style attrubultes here wordpress.stackexchange.com/questions/193167/… – pickos7 Jun 6 at 16:58
  • Ah ok, sorry for misunderstanding, it's just that your first example is a class so I thought that was an option available to you. If you're picking from a colour picker then you'd have to do an inline style like your second option. – Rick Curran Jun 7 at 8:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.