Title: Custom css class for attribute value
Last modified: February 10, 2022

---

# Custom css class for attribute value

 *  Resolved [cousinr](https://wordpress.org/support/users/cousinr/)
 * (@cousinr)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/custom-css-class-for-attribute-value/)
 * Hi,
    Since there is no default way to add Html codes to the attribute value name,
   I am looking for a solution to add a class for each attribute value to assign
   colors, size and font family to Glyph icons. Attribute values will be displayed
   in product comparison tables and product specification tabs. For exemple: Colors:–.
   green {color:green;} – .yellow {color:yellow;} How do I do this with a snippet
   or other way?

Viewing 6 replies - 1 through 6 (of 6 total)

 *  [Igor H](https://wordpress.org/support/users/ihereira/)
 * (@ihereira)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/custom-css-class-for-attribute-value/#post-15353108)
 * Hello,
 * Have you checked this [article](https://stackoverflow.com/questions/46084998/adding-woocommerce-css-classes-for-attributes)?
   It shows an example of how to do that, not with colors, you can edit it according
   to your needs.
 * Please note since this is a development topic. I’m going to leave it open for
   a bit to see if anyone is able to chime in to help you out.
 * We also recommend [the WooCommerce Developer Resources Portal](https://developer.woocommerce.com/)
   for resources on developing for WooCommerce.
 * As well as [WooCommerce Facebook group](https://www.facebook.com/groups/advanced.woocommerce/)
   or the `#developers` channel of the [WooCommerce Community Slack](https://woocommerce.com/community-slack/).
 * Thanks.
 *  Thread Starter [cousinr](https://wordpress.org/support/users/cousinr/)
 * (@cousinr)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/custom-css-class-for-attribute-value/#post-15354046)
 * Hello [@ihereira](https://wordpress.org/support/users/ihereira/),
    Yes, I saw
   it before I posted here. The author suggests changing the wocommerce file, but
   that’s not the best solution. It would be good if you could help to add the code
   through the snippet. Thanks
 *  [MayKato](https://wordpress.org/support/users/maykato/)
 * (@maykato)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/custom-css-class-for-attribute-value/#post-15355495)
 * Hi [@cousinr](https://wordpress.org/support/users/cousinr/)
 * You can get some more insights from the articles below.
    [https://stackoverflow.com/questions/58594970/woocommerce-add-class-to-variation-dropdown](https://stackoverflow.com/questions/58594970/woocommerce-add-class-to-variation-dropdown)
   [https://stackoverflow.com/questions/54841801/add-a-custom-class-to-variation-options-displaying-out-of-stock-in-woocommerce](https://stackoverflow.com/questions/54841801/add-a-custom-class-to-variation-options-displaying-out-of-stock-in-woocommerce)
 * However, customization is beyond the scope of support we are able to provide 
   in this forum. If you need further help, I’d recommend asking on the Facebook
   group and Community Slack as [@ihereira](https://wordpress.org/support/users/ihereira/)
   suggested, or getting in touch with a web developer: [https://woocommerce.com/customizations/](https://woocommerce.com/customizations/)
 *  Thread Starter [cousinr](https://wordpress.org/support/users/cousinr/)
 * (@cousinr)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/custom-css-class-for-attribute-value/#post-15355901)
 * Hi [@maykato](https://wordpress.org/support/users/maykato/) ,
    Unfortunately 
   these articles are useless to me. I am not going to make color switches. I need
   to display symbols in the product specification tab in the attribute table <i
   class=”fa-solid fa-check”></i> in green or <i class=”fa-solid fa-xmark”></i> 
   in red, for example. I can’t give these attribute names because the html tags
   are removed when saving. Can you suggest a hook with examples that I can use 
   to connect to attribute conditions to add a field to assign class to attribute
   values. Then I can add a different css for each value. Thanks
 *  [Igor H](https://wordpress.org/support/users/ihereira/)
 * (@ihereira)
 * [4 years, 4 months ago](https://wordpress.org/support/topic/custom-css-class-for-attribute-value/#post-15357057)
 * Hi [@cousinr](https://wordpress.org/support/users/cousinr/),
 * We understand what you are saying, as mentioned previously, we’ll leave this 
   forum topic open to see if anyone else might suggest an alternative solution.
 * In the meantime, you can reach out to the channels already provided to look for
   further assistance.
 * I hope this provides clarity. Thank you.
 *  [MayKato](https://wordpress.org/support/users/maykato/)
 * (@maykato)
 * [4 years, 3 months ago](https://wordpress.org/support/topic/custom-css-class-for-attribute-value/#post-15388147)
 * This thread has been inactive for a while, so I’m going to mark this as resolved–
   if you have any further questions, you can start a new thread.

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘Custom css class for attribute value’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

 * 6 replies
 * 3 participants
 * Last reply from: [MayKato](https://wordpress.org/support/users/maykato/)
 * Last activity: [4 years, 3 months ago](https://wordpress.org/support/topic/custom-css-class-for-attribute-value/#post-15388147)
 * Status: resolved