# How to get style attribute with Browser Library

**URL:** <https://forum.robotframework.org/t/how-to-get-style-attribute-with-browser-library/4988>\
**Category:** Browser\
**Created:** [25 November 2022 15:47 UTC](https://forum.robotframework.org/t/how-to-get-style-attribute-with-browser-library/4988 "2022-11-25T15:47:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wassupdev](https://dub1.discourse-cdn.com/flex005/user_avatar/forum.robotframework.org/wassupdev/32/1741_2.png) [@wassupdev](https://forum.robotframework.org/u/wassupdev)\
**Post date:** [25 November 2022 15:47 UTC](https://forum.robotframework.org/t/how-to-get-style-attribute-with-browser-library/4988/1 "2022-11-25T15:47:35Z")

</div>

So, i’m trying to make my automation validate the color of a text element using Browser Library  
Then I tried the following line:

```
${element_style}= Get Attribute xpath=//span[contains(text(),"text to be validated")] style 
${style_txt}= Get Text ${element_style}
Should Contain ${style_txt} rgb(1,1,1)

```

But that just returns nothing for ${element\_style} variable

---

<div class="post-metadata">

**Author:** ![\_daryl](https://avatars.discourse-cdn.com/v4/letter/_/45deac/32.png) [@\_daryl](https://forum.robotframework.org/u/_daryl)\
**Post date:** [25 November 2022 16:21 UTC](https://forum.robotframework.org/t/how-to-get-style-attribute-with-browser-library/4988/2 "2022-11-25T16:21:38Z")

</div>

If you are after the style then If I’m not mistaken you can use the ‘Get Style’ keyword that the browser library offers, so it would look something like this:

```
${element_style}= Get Style //span[contains(text(),"text to be validated")] color
Should Contain ${element_style} rgb(1,1,1)

```

This should work provided the XPath is correct for returning the “style color value” for that element.
