Your sites Log in Sign up Menu

How to change text color within a post?

I would like to set a color for particular sections of text in my post. The intended use would be something like:

Shall I compare thee to a summer’s day?

Thou art more lovely and more temperate:

Rough winds do shake the darling buds of May,

And summer’s lease hath all too short a date;

I want to make the bolded text red, and the italicized text blue.

I am currently using the stock Blog template and uploading my posts as .docx files. (My bold/italics/underline and embedded images upload this way, but not text colors.) Where do I change my process to let me apply color to particular passages of text? Should I be uploading in a different file format, or modifying style.css in the Blog template?


8 months ago, 1 replies   how   color   Improve this question

I'd probably add some custom metadata to your post, which we can then access in your template to inject some CSS for particular posts. For example, let's say you set the following custom metadata in your post:

Colors: yes

Shall I compare thee to...

You can then add something like this to your template's entry.html file:

{{#entry.metadata.colors}}
<style type="text/css">
.entry b {color: red}
.entry i, .entry em {color: blue}
</style>
{{/entry.metadata.colors}}

This answer provides a sketch of a solution, rather than a specific implementation. Please let me know if you have any questions about the details, I'd be happy to elaborate

Answered 8 months ago · Improve this answer