Your Markdown HTML is not picking up the styles because of Astro’s scoped styles and how they are applied to slotted Markdown content.
In your layout, styles like:
<style>
#content-page-1401 .cs-color { … }
</style>
are compiled to something like:
#content-page-1401[data-astro-cid-XXXX] .cs-color[data-astro-cid-XXXX] { … }
and only apply to elements that have the same data-astro-cid-XXXX attribute. Elements coming from Markdown and rendered into <slot /> do not get that attribute, so the scoped selector no longer matches. [Styling in Astro]
You have two main options:
1. Make the styles global in the layout
Use is:global so the CSS is not scoped and will match the Markdown HTML:
<style is:global>
#content-page-1401 .cs-title {
/* your styles */
}
#content-page-1401 .cs-color {
/* your styles */
}
</style>
Global styles are recommended for styling Markdown content from a layout. [Markdown Styling]
2. Use a wrapper + :global() for children
Keep the layout styles scoped, but explicitly target the slotted Markdown via :global():
<!-- Layout.astro -->
---
const { frontmatter } = Astro.props;
---
<div id="content-page-1401">
<slot />
</div>
<style>
/* Scoped to this component, but applies globally to children */
#content-page-1401 :global(.cs-title) {
/* your styles */
}
#content-page-1401 :global(.cs-color) {
/* your styles */
}
</style>
This pattern (scoped parent + :global() for children) is specifically recommended for styling content like blog posts or Markdown. [Styling in Astro]