> 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="https://1548664070-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWKNnJmhJBQwhdk5WBFsi%2Fuploads%2Fgit-blob-9f7520ed1f339197a775ed8f0926b4264117a729%2Fimage.png?alt=media" 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
