Back to all resources
CSS
rich text
first child
last child

Richtext Reset

By Jared Malan
This CSS code snippet is designed to adjust the margins of elements within a rich text container, specifically targeting the first and last child elements. The first rule removes the top margin of the first child element inside any element with the class .w-richtext. This is achieved by setting margin-top to 0 and using !important to ensure this rule takes precedence over any other conflicting styles.

The second rule removes the bottom margin of the last child element within the same .w-richtext container. It also specifically targets the last list item (li) within ordered lists (ol) and unordered lists (ul) inside the .w-richtext container. Similar to the first rule, it sets margin-bottom to 0 and uses !important to enforce this style.