Your app's existing CSS continues to work exactly as before.
When you render a diff using HTML Diff, it only adds data-diff-status attributes to highlight changes. It does not modify your existing HTML structure or styling. The exception is when you opt in to specific behaviors using data-diff-mode attributes, which allows for more control over how diffs are displayed.
Each changed element receives one of these attributes:
data-diff-status="added" — applied to newly added elementsdata-diff-status="modified" — applied to modified elementsdata-diff-status="removed" — applied to removed elementsNotice how:
primary-btn and large-size classes remain untouchedid and data-diff-key attributes are preserveddata-diff-status="modified" was added to highlight the change.primary-btn and .large-size continues to workA default stylesheet is provided with the package:
Or, add it to your HTML:
You can override these styles in your own CSS for custom themes or branding:
Because diff metadata is attached via data-diff-status, your components keep their original classes intact. You simply target the attribute in CSS:
You can now scope your override styles with attribute selectors and a wrapper around the rendered diff.
Attribute selectors have the same specificity as classes. Bare selectors like [data-diff-status="added"] can lose to app content styles such as .content h2, .prose a, pre code, or .pricing-table td, especially when those rules load later or have higher specificity.
Prefer scoping diff styles under the element that contains the rendered diff:
If your app has stronger content selectors, match that context in your diff styles:
This ensures your app's layout and design remain intact while only the diff highlighting is added on top.