> For the complete documentation index, see [llms.txt](https://help.sdocs.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.sdocs.com/sdocs/template-architecture/template-authoring/css-styling-with-merge-fields.md).

# CSS Styling with Merge Fields

This how-to article will explain how you would use merge fields to add a layer of styling that could be tied to an object.

### ![thinking face](https://pf-emoji-service.prod-east.frontend.public.atl-paas.net/assets/standard/ef8b0642-7523-4e13-9fd3-01b65648acf6/32x32/1f914.png) Example Use Case <a href="#example-use-case" id="example-use-case"></a>

You have an object that has a specific field tied to a CSS element.

Example: An opportunity has a field you’d like to utilize as a CSS attribute. In this case, the opportunity has a Color field and a color associated with it.

![blue book](https://pf-emoji-service.prod-east.frontend.public.atl-paas.net/assets/standard/ef8b0642-7523-4e13-9fd3-01b65648acf6/32x32/1f4d8.png) Instructions

{% stepper %}
{% step %}
**Create the field**

* Go to Setup > Object Manager > the object you wish to update
* Go to Fields & Relationships and click the New button to create a new field
* Set as Text with a length of 255
  {% endstep %}

{% step %}
**Set the CSS attribute on the record**

* Go to the record you wish to update
* Add the CSS attribute to the field you just created (ex: #C2BFA5)
  {% endstep %}

{% step %}
**Leverage the CSS attribute in a template**

```
<div style="background-color:{{!Opportunity.test_color__c}};">TEST TEXT</div>
```

{% endstep %}
{% endstepper %}

#### Output

<figure><img src="/files/V1fzoL3MRASh979Arywe" alt=""><figcaption></figcaption></figure>

{% hint style="info" %}
There can be many other uses for CSS merge fields, this is just a single example.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://help.sdocs.com/sdocs/template-architecture/template-authoring/css-styling-with-merge-fields.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
