# PR: Fix Insufficient Text-to-Background Contrast in Code Blocks (Issue #886) #998
+20
−8
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem / Issue
function
keyword, had insufficient text-to-background contrast (e.g.,#D73A49
on#F7F7F7
), failing WCAG 2.1 AA (minimum 4.5:1 contrast ratio)..code-box
,bg-bg-gray-40
) was overriding the background, muting the intended high-contrast theme.<span style="color:#D73A49">function</span>
as having a contrast ratio of 4.26:1 (below 4.5:1).How We Checked for the Issue
http://localhost:4321/tutorials/get-started/
..code-box
,bg-bg-gray-40
, and color overrides.How We Tackled It
bg-bg-gray-40
class from code block containers to prevent the light gray background from overriding the theme..code-box
background to pure white (#fff
) in the main global styles for maximum contrast.function
keyword to black, as it was a workaround, not a real fix.code-contrast-fix.scss
file and its import.What Changes Were Made
src/components/CodeContainer/index.astro
to removebg-bg-gray-40
from code block classes.styles/global.scss
to set.code-box { background-color: #fff !important; }
and removed the import forcode-contrast-fix.scss
.src/styles/code-contrast-fix.scss
..code-box
or.astro-code
in the codebase.How We Ensured the Issue Was Tackled
Next Steps
This PR closes #886 and ensures all code blocks meet WCAG 2.1 AA contrast requirements.