How can I customize the color of the title and property value in Handlebars?

Here is the list I am working with:

<li>Equipment Area:{{equipment_area}}</li>
<li>Equipment Type: {{equipment_type}}</li>
<li>Manufacturer: {{manufacturer}}</li>
<li>Model Number: {{model_number}}</li>
<li>Serial Number: {{serial_number}}</li>
<li>Service: {{service}}</li>
<li>Capacity: {{capacity}}</li>
<li>Comments: {{general_comments}}</li>
<li>Total Cost: {{total_of_new_installation}}</li>

When attempting to change the font color of the titles to blue, I added inline styling:

<li style="blue">Equipment Area:{{equipment_area}}</li>

Unfortunately, using this inline style affects both the title and value in the list item.

I am looking for a way to only make the title blue while keeping the template value white. Is there any solution for this?

Answer №1

Give this method a shot:

<li style="blue">Equipment Area:<p style="color: white;">{{equipment_area}}</p></li>

Answer №2

Enclose every section in a span and assign it a specific class, similar to this example:

<li>
   <span class="section-title">Category:</span>
   <span class="section-value">{{category}}</span>
</li>

This allows you to customize the styling of each class according to your preference...

Answer №3

By utilizing inline styling, you have the ability to easily define the color of text within an HTML span tag using the color property.

<li><span style="color: blue">Equipment Area:</span><span style="color: white">{{equipment_area}}</span></li>
<li><span style="color: blue">Equipment Type:</span><span style="color: white">{{equipment_type}}</span></li>
<li><span style="color: blue">Manufacturer:</span><span style="color: white">{{manufacturer}}</span></li>
<li><span style="color: blue">Model Number:</span><span style="color: white">{{model_number}}</span></li>

To streamline the process and avoid repetitive inline styling on each line item, it is recommended to assign title and value classes to the spans and apply styles via CSS, as shown below:

.title {
  color: blue;
}

.value {
  color: white;
}
  
.title:hover {
  color: red;
}
<li>
  <span class="title">Equipment Area:</span>
  <span class="value">{{equipment_area}}</span>
</li>

<li>
  <span class="title">Equipment Type:</span>
  <span class="value">{{equipment_type}}</span>
</li>

<li>
  <span class="title">Manufacturer:</span>
  <span class="value">{{manufacturer}}</span>
</li>

<li>
  <span class="title">Model Number:</span>
  <span class="value">{{model_number}}</span>
</li>

(the code snippet has been updated to change the color of titles to red when hovering over them)

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Identify the Presence of Hover Functionality

For a while now, the trend has been leaning towards feature detection. I am interested in determining whether a visitor's browser supports the :hover pseudo class. With many mobile devices not supporting hovering, I want to adjust my event listeners a ...

Tips on showing a response in an HTML node with Node.js and AngularJS

Just starting out with NodeJS and AngularJS. My goal is to fetch a response from an external site and display it in Angular JS. I managed to send the request and receive a response, but on the UI JSON appears as a string with forward slashes "\". For ...

The problem with floating labels

I have been attempting to incorporate the floatlabels feature from floatlabels, but I am encountering difficulties in getting it to work properly. Here is the sequence of steps I have taken: Firstly, I include the JS file <script src="js/floatlabels. ...

Is Firebase the Answer to Shopify's Authentication Validation?

I've been following this tutorial on building a Shopify app using Node, Nextjs, and React. Progress has been smooth so far, but I've now reached a point where I need to store some of my app data in Firestore. My current approach involves utiliz ...

Steps to gather all the images within a directory

Take a look at this demo When you click on the "next" button, new images are loaded from the internet. In my application, all the images are stored in the img/image folder with names like 1.jpg, hi.png, etc. My question is, how can I display these image ...

How can you retrieve Azure App Settings as an object with Node.js?

Can Node/Express in Azure be utilized to handle app settings as an object, akin to ASP.NET Core? For instance, if the app settings are: container:value1 = "Hello", container:value2 = "World" The goal is to retrieve an object for "container" that provide ...

Struggle with the background div menu

I am trying to create a menu with a background color, but when I use "background" or "background-color" on the div that contains my menu, I can't see any color. It's frustrating because I know it should be working.. Here is the HTML : <head ...

I am looking for a way to create a fixed bottom navbar that evenly spreads out the links across the entire width of the screen. It should also be responsive

:) I'm experimenting with my fixed bottom navbar in bootstrap.. It's working to some extent.. But unfortunately, the links in my navbar won't justify.. I've tried everything I can think of.. I want it to be responsive so the current ...

"Troubleshooting: Click counter in HTML/Javascript unable to function

My latest HTML project is inspired by the "cookie clicker" game, and I'm working on it for a friend. So far, I've managed to get the click counter to function to some extent. Essentially, when you click on the image, the number at the bottom sho ...

Add a flexible element to a container without disrupting the alignment of the other

I'm facing a challenge in adding an action button to the end of a grid layout without affecting the centering of the items. The button should seamlessly fit into the grid, just slightly offset. If you check out my demo, you'll see what I mean. ...

Learn how to align a form to the right using HTML, CSS, and Bootstrap

I am completely new to front-end technology. I have been attempting to write some code for my backend app using Html, Css, and Bootstrap. Currently, I am trying to place a search form on the right side of my webpage. Can anyone help me figure out what I am ...

I am looking to showcase a text directly from the properties file using the thymeleaf template engine

I have two files named message_ar.properties and messages_fr.properties for internationalization purposes. Within my HTML file, I am attempting to show the correct label for a confirm message. To accomplish this, I am utilizing Thymeleaf as my template e ...

Creating a dynamic nested list in HTML using JavaScript with data retrieved from a JSON source

I'm trying to generate a dynamic nested ul\li list from a JSON array. IMPORTANT! While I can use jQuery for this transformation, it's in a node.js environment where DOM access is restricted and I must work with a string. The depth of the a ...

Executing JavaScript function from external SVG file globally

I am working on an HTML page that includes an external JavaScript module <script type="text/javascript" src="js/js.js"></script> and also an external SVG map called "img/map.svg". My goal is to create clickable objects on the map that will t ...

Is the CSS after-before property not functioning properly?

In my CSS code, I am utilizing the after and before tags. This is the structure of my div. However, I am facing an issue where my after tag is not functioning as expected. While everything else seems to be working fine, the after and before tags are not di ...

How come adjusting the margin of a div doesn't impact the placement of its child elements?

I'm trying to wrap my head around how css margins interact with divs and their child elements. For instance, when I set it up like this... <div style="clear: both; margin-top: 2em;"> <input type="submit" value="Save" /> </div> ...

Using CSS :hover for elements with dual classes only

Is there a way to make the CSS :hover selector work only when two different classes are attached to a div? I have tried a couple of methods, but they eliminate the hover effect. For example: .accordionButton .cyan:hover{ color: cyan; } I cannot s ...

How can the value of a button be displayed in an input box using an onclick function?

When the button '1' is clicked, it displays the value "1" inside a <!p> tag. However, the second button '2' does not display the value "2" in the input box. Even though both functions are identical. //Function with working func ...

Setting up node version 6.10.3 as a required NPM package

Currently working on projects utilizing the serverless framework to eventually be deployed to AWS Lambda, my end goal is to have them run seamlessly with the same version of node that is supported on AWS Lambda - which happens to be node 6.10.3. Despite ad ...

Choosing Only the Visible Element with CSS

Within my program, there exists a text element that appears in two distinct sections: section A and section B (in the form of a popup). My intention was to create one object using CSS that could be utilized in both areas. By doing so, I would be able to em ...