0

Upfront, before anyone asks: yes, I've googled this and I've read every single article on every dodgy blog site instructing me to:

  1. Create a CSS file and drop in the Style Library.
  2. Write some CSS with .ms-rteStyle-whatever and/or .ms-rteElement-whatever.
  3. Reference it in my master page.
  4. Check in and publish all the things.

Also, I've already seen this question and subsequent comment, and I'm not using a custom new or edit form. Just a custom list with an enhanced rich text site column.

The advertised method for adding custom styles works great... for wiki content on pages. Unfortunately, that's not what I need. I need to be able to offer these custom style options in an enhanced rich text column on a custom list. Anyone know what I'm doing wrong, or what I need to do?

2
  • Have you checked this post? rules.ssw.com.au/…
    – Aveenav
    May 18, 2017 at 21:50
  • Yes. And this is still about that page content field you see on publishing pages. Ultimately, I gave up trying to get my custom styles to appear as options in the multiline text field and just added the html content field and am using that. May 19, 2017 at 13:00

1 Answer 1

2

Try the following css:

/* Overriding H3 in the ribbon */
H3.ms-rteElement-H3 {
    -ms-name: "Heading 3";
    -ms-element: "true";
    font-family: Helvetica,Arial,sans-serif;
    font-size: 24px;
    font-weight: normal;
    color: Green;
}


/* Adding custom H5 in the ribbon */
H5.ms-rteElement-H5 {
    -ms-name: "My Custom Heading 5";
    -ms-element: "true";
    font-family: Helvetica,Arial,sans-serif;
    font-size: 18px;
    font-weight: normal;
    color: Red;
}



/* For multi-line text field */
.ms-rtestate-field h5, .ms-rtestate-field .ms-h5 {
    line-height: 1.6;
    font-family: Helvetica,Arial,sans-serif;
    font-size: 18px;
    font-weight: normal;
    color: Red;
}

.ms-rtestate-field h3, .ms-rtestate-field .ms-h3 {
    font-family: Helvetica,Arial,sans-serif;
    font-size: 24px;
    font-weight: normal;
    color: Green;
}
/* @end */

enter image description here

3
  • So, I'ma mark this as the answer because what you wrote above does work. Unfortunately, it's not going to work for my implementation, as it looks like, in order for this to work, the rteElement has to point at a specific HTML element. May 22, 2017 at 16:42
  • Actually, I take that back. I can use this, but a couple of notes: 1. You don't need the second set of styles (the ones that use .ms-rtestate-field h5, .ms-rtestate-field .ms-h5). 2. It has to be Heading elements, nothing else works. May 22, 2017 at 16:53
  • 1
    I think you may need the second set for display or list view. Else once you move away from the form, you'd lose your styles. I agree only heading elements worked. There may be some additional way of adding new elements but I haven't explored enough.
    – Aveenav
    May 22, 2017 at 17:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.