Personalizing the hues of text in WordPress

Embarking on my coding journey, I have delved into online courses and now aim to enhance my skills by constructing a Wordpress Child Theme.

As I delve further into customization, I encounter the dilemma of text color alteration through two main methods:

1) Utilizing css

2) Within the wordpress dashboard:

https://i.sstatic.net/p5j1n.png

If I opt for changing text color via css, it may revert back when modified in the wordpress dashboard. This leads me to ponder - how can I selectively preserve certain text colors using css while allowing flexibility for others within the dashboard?

Despite attempting color: #000000 !important; in my css code, the desired permanence remains elusive. Is there a definitive solution to lock text color changes permanently via css?

Answer №1

When you adjust the color in the WordPress Editor, it will automatically update the color using CSS as well. For instance, if you highlight text in the editor and change its color by clicking on one of the provided colors, the resulting HTML will contain inline CSS. Refer to http://www.w3schools.com/css/css_howto.asp The only way to override styles set like this is by applying a style with !important on the same HTML element where the inline CSS is used.

For example: If you apply the color to body with !important - the inline style of the inner DIV remains. However, if you uncomment the .colorize class, it will take precedence over the inline CSS color.

body {
  color:orange!important;
}
/* Uncomment this to overwrite the inline CSS
.colorize {
  color:yellow!important;
}
*/
<html>
<body>
  <div>
    Content outer DIV
    <div class="colorize" style="color:blue;">
      Content inner DIV
    </div>
  </div>
</body>
</html>

It's important to note that you should avoid using !important whenever possible. In your specific situation, it's typically best to customize the WordPress editor to restrict the available colors or only allow certain ones to be applied.

Answer №2

By utilizing the parent element's class, you have the ability to apply styles that will be inherited by its child elements.

<html>
<body class="home">
  <div class="main">
      <div class="colorize">
      Content inner DIV
    </div>
  </div>
</body>

Parent theme :

<style>
.colorize{
    color:red;
}
</style>

Child theme:

<style>
.main .colorize{
    color: green; //override using parent element class(main)
}
</style>

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

Jquery Toggle not applying class change on mobile devices

Check out my website: . There's a menu option called Services with a dropdown feature. Here is the code for it: <li class="dropdown menu-services"><a class="dropdown-toggle" href="#" data-toggle="dropdown" data-target="#">Services <b c ...

Having trouble arranging the elements when swapping within a pop-up modal

When I drag and drop two divs inside a modal popup, their positions shift down during the animation. I am struggling to fix this issue. HTML Code: <title> Tile Swapping with Animation</title> <body> <button type="button" class=" ...

Another choice for object-fit:contain workaround for IE

Is there an alternative option to object-fit: contain that is compatible with Internet Explorer? Below is a snippet of my code: .cbs-Item img { height: 132px ! important; width: 132px ! important; object-fit: contain; <div class="cbs-Ite ...

Captivating images paired with informative captions

I am trying to display a picture with a description inline, but I am facing some issues. While I was able to align two pictures using div block:inline, adding a description to the first picture caused it to extend in width (despite setting margin: 0 and a ...

Issues with absolutely positioned slideshows

Currently, I am attempting to design a slideshow using absolute positioning to layer images on top of each other. However, I am encountering a problem where the text below the slideshow is also being stacked on top of the pictures. I have tried enclosing t ...

Tips for adding a border to a 3D pie chart in Highcharts

I created a 3D pie chart using the Highchart plugin and wanted to add borders to each portion. I tried adding the following code: borderWidth: 4, borderColor: "red" within the plotOptions: pie: section. However, I noticed that the portions were getting b ...

Arranging text in a straight line using Flexbox

I've been trying to figure out the best way to align these two items. When you view the code snippet, you'll notice that 'Newsletter' is slightly lower than 'Resources'. Both are supposed to be aligned both vertically and hori ...

Creating Visuals with CSS Gradients: A Tutorial on Generating Images and SVG Files

I currently have a CSS gradient applied and I am interested in creating an image or SVG file from it. However, I am unsure of how to accomplish this task. Any advice would be greatly appreciated. background: -webkit-linear-gradient(bottom, rgb(211, 208, ...

Implementing automatic page breaks in Laravel using the mpdf libraryLet me know

I am attempting to automatically add a page break if the data exceeds 10. I am using mpdf in conjunction with Laravel and Vue. Below is my CSS code: <style> div.breakNow { page-break-inside:avoid; page-break-after:always; } </style> This is t ...

The Bootstrap div is failing to resize proportionately

Although frontend development is not my expertise, I find myself needing to make adjustments to a Bootstrap-based website. I have been tweaking the heights of a specific div that is defined as follows: html: <div class="cover-container d-flex w-100 h- ...

Showcasing two columns side by side in the first row and one column beneath them in the second row within a single tr

Here is the code snippet I created: <table> <tr> <th>Month</th> <th>Savings</th> </tr> <tr> <td>January</td> <td>$100</td> </tr> <tr> <td& ...

Solving issues with flexboxes in Safari 5.1.7 on Windows

I am currently utilizing flex boxes for managing the layouts of my website. However, it seems that the Safari version for Windows (5.1.7) is outdated and causing all flex boxes to be dysfunctional. On MacOS systems, the same version 12.x works correctly. ...

Tips on customizing the appearance of the "time" input type

Are there any resources that explain how to style the input type "time" completely? I have been searching but unable to find a comprehensive guide with all the necessary style attributes! The only example I came across is: input[type="time"]{ /**styl ...

How can you easily center content vertically on a web page?

There has been plenty of back-and-forth regarding this issue, with proposed solutions ranging from pure CSS to pure HTML. Some can get quite complex, involving deeply nested divs and intricate CSS rules. I'm looking for a simple and uncomplicated answ ...

Problem with CSS styling the BODY element

It's been a while since I've worked on any CSS/HTML development, and I'm facing some challenges with styling the body tag using CSS. My goal is to have the HTML tag styled with a background color, and then style the body tag to be 80% width ...

The challenge of responsivity in my custom lightbox design

Web Design <div class="image-gallery"> <img> </div> <div class="dark" id="photo-gallery"> <div class="container"> <h1>Photo Gallery</h1> <div class="images"> <a href="#" data-image=""& ...

In the Firefox browser, tables are shown with left alignment

I recently designed a responsive HTML newsletter with all images neatly wrapped in tables. My goal was to ensure that on smaller screens, the tables stack on top of each other for better readability, while on wider displays, they appear side by side in a r ...

Tips for adding a removal icon to the top corner of an uploaded image

https://i.sstatic.net/eztiy.png <div *ngFor="let selected of base64textString;let index = index"> <img [src]="selected.imageString" style="height: 100px; width:100px;"> <i class="ft-trash-2 da ...

What is the best way to set a minimum width for websites with relative (%) widths that are compatible with IE6 and above?

I am working on a website where I utilize percentages (%) for widths to create a flexible layout. However, I am encountering an issue where everything breaks at a certain width, such as 800px. Is there a way to set a maximum width of 800px and then displa ...

Avoid showing numerical or bullet points for ordered or unordered lists

Hey everyone, I'm currently using the code below to create some list items within an ordered list. $output = '<div id="menu_options">'; $output .= '<ol class="tabs">'; foreach($menu_items as $menu){ $output .= &ap ...