Skip to content

Instantly share code, notes, and snippets.

@seflless
Created September 29, 2025 14:31
Show Gist options
  • Select an option

  • Save seflless/96438da540081767e0e68a591082a19e to your computer and use it in GitHub Desktop.

Select an option

Save seflless/96438da540081767e0e68a591082a19e to your computer and use it in GitHub Desktop.
We should be more playful with colors in markdown files.

πŸ“š Colorful Markdown Guide

Making sections pop with organized color schemes

<style> /* Dark mode adaptations for colored sections */ @media (prefers-color-scheme: dark) { .blue-section { background: linear-gradient(135deg, #1e3a8a 0%, #1e40af 100%) !important; color: #e0e7ff !important; border-left-color: #3b82f6 !important; } .green-section { background: linear-gradient(135deg, #14532d 0%, #166534 100%) !important; color: #dcfce7 !important; border-left-color: #22c55e !important; } .yellow-section { background: linear-gradient(135deg, #92400e 0%, #b45309 100%) !important; color: #fef3c7 !important; border-left-color: #f59e0b !important; } .yellow-section > * { color: #fef3c7 !important; } .yellow-section blockquote { color: #fef3c7 !important; } .yellow-section blockquote * { color: #fef3c7 !important; } .yellow-section blockquote strong { color: #fef3c7 !important; font-weight: 600; } .purple-section { background: linear-gradient(135deg, #581c87 0%, #7c3aed 100%) !important; color: #f3e8ff !important; border-left-color: #a855f7 !important; } .red-section { background: linear-gradient(135deg, #7f1d1d 0%, #dc2626 100%) !important; color: #fecaca !important; border-left-color: #ef4444 !important; } .orange-section { background: linear-gradient(135deg, #9a3412 0%, #ea580c 100%) !important; color: #fed7aa !important; border-left-color: #fb923c !important; } } /* Warning text styling - dark in light mode, bright in dark mode */ .warning-text { color: #451a03 !important; /* Dark text for light mode */ } .warning-text * { color: inherit !important; } .warning-text blockquote { color: inherit !important; } .warning-text blockquote * { color: inherit !important; } @media (prefers-color-scheme: dark) { .warning-text { color: #fef3c7 !important; /* Bright text for dark mode */ } .warning-text * { color: #fef3c7 !important; } .warning-text blockquote { color: #fef3c7 !important; } .warning-text blockquote * { color: #fef3c7 !important; } } </style>

Color Coding System

This document demonstrates how to use colors in markdown to create visual hierarchy and make content more scannable, especially when LLMs generate documentation.

Color Palette

  • Blue: Main concepts and definitions
  • Green: Examples and code snippets
  • Yellow: Important notes and warnings
  • Purple: Advanced topics and deep dives
  • Red: Critical information and gotchas
  • Orange: Tips and best practices

Accessibility & Navigation

This document uses proper markdown headers (##, ###) that:

  • Create linkable anchors (e.g., #core-concepts, #advanced-techniques)
  • Work with automatic outline generators and table of contents
  • Support keyboard navigation and screen readers
  • Meet WCAG AA contrast standards (4.5:1 ratio minimum)
  • Maintain semantic structure while adding visual enhancement

Table of Contents


Core Concepts

What is Color-Coded Markdown?

Color-coded markdown uses HTML <div> elements with inline CSS to create visually distinct sections. This approach works in most markdown renderers and provides:

  • Visual hierarchy beyond just heading levels
  • Quick scanning for specific content types
  • Better organization for complex documents
  • Enhanced readability for LLM-generated content

Basic Implementation

Here's how to create colored sections:

<div
  style="background: #your-color; padding: 20px; border-radius: 12px; border-left: 5px solid #accent-color;"
>
  Your content here
</div>

πŸ’‘ Pro Tip: Use CSS media queries for dark mode compatibility:

@media (prefers-color-scheme: dark) {
  .colored-section {
    background: #darker-version;
    color: #lighter-text;
  }
}

Key CSS Properties:

  • background: Solid color or gradient
  • padding: Internal spacing
  • border-radius: Rounded corners
  • border-left: Accent stripe
  • margin: External spacing

Important Notes

⚠️ Compatibility Warning: Not all markdown renderers support HTML/CSS. Test in your target environment first.

Supported Platforms:

  • βœ… GitHub (with some limitations)
  • βœ… GitLab
  • βœ… Most documentation sites
  • βœ… Many markdown editors
  • ❌ Plain text viewers

Advanced Techniques

Dark Mode Support

For proper dark/light mode compatibility, use CSS custom properties and media queries:

:root {
  --section-bg: #f8f9ff;
  --section-text: #1e293b;
  --accent-color: #1e40af;
}

@media (prefers-color-scheme: dark) {
  :root {
    --section-bg: #1e3a8a;
    --section-text: #e0e7ff;
    --accent-color: #3b82f6;
  }
}

.colored-section {
  background: var(--section-bg);
  color: var(--section-text);
  border-left: 5px solid var(--accent-color);
}

Gradient Backgrounds

Use CSS gradients for more sophisticated looks:

background: linear-gradient(135deg, #color1 0%, #color2 100%);

Nested Color Sections

You can nest colored sections for sub-categories:

Sub-section Example This creates a layered effect with transparency.

Responsive Design

Consider mobile viewing:

@media (max-width: 768px) {
  .colored-section {
    padding: 15px;
  }
}

Critical Information

Common Pitfalls

  1. Overuse: Too many colors can be overwhelming
  2. Accessibility: Ensure sufficient contrast ratios
  3. Consistency: Stick to your color scheme
  4. Performance: Inline CSS can bloat large documents

What to Avoid

  • Neon colors that hurt the eyes
  • More than 6 different color categories
  • Colors that don't work in dark mode
  • Inconsistent application of the color system

Best Practices & Tips

Pro Tips

  1. Start Simple: Begin with 3-4 colors maximum
  2. Use Icons: Combine colors with emojis for better recognition
  3. Test Readability: Ensure text remains legible
  4. Document Your System: Create a legend like this document
  5. Be Consistent: Apply the same color to the same content type

When to Use Colors

  • Tutorials: Different steps or difficulty levels
  • Documentation: API sections, examples, warnings
  • Meeting Notes: Action items, decisions, follow-ups
  • Research: Different sources or confidence levels
  • LLM Output: Generated content that needs organization

Implementation Examples

Quick Reference Card

Light Mode Examples:

<!-- Definition -->
<div
  style="background: #f8f9ff; padding: 15px; border-radius: 8px; border-left: 4px solid #1e40af; color: #1e293b;"
>
  **Term**: Explanation here
</div>

<!-- Example -->
<div
  style="background: #f0fdf4; padding: 15px; border-radius: 8px; border-left: 4px solid #16a34a; color: #14532d;"
>
  **Example**: Code or usage example
</div>

<!-- Warning -->
<div
  style="background: #fefce8; padding: 15px; border-radius: 8px; border-left: 4px solid #ca8a04; color: #451a03;"
>
  **⚠️ Warning**: Important notice
</div>

Dark Mode Examples:

<!-- Definition -->
<div
  style="background: #1e3a8a; padding: 15px; border-radius: 8px; border-left: 4px solid #3b82f6; color: #e0e7ff;"
>
  **Term**: Explanation here
</div>

<!-- Example -->
<div
  style="background: #14532d; padding: 15px; border-radius: 8px; border-left: 4px solid #22c55e; color: #dcfce7;"
>
  **Example**: Code or usage example
</div>

<!-- Warning -->
<div
  style="background: #92400e; padding: 15px; border-radius: 8px; border-left: 4px solid #f59e0b; color: #fef3c7;"
>
  **⚠️ Warning**: Important notice
</div>

Color Scheme Variations

Theme Options

Accessible Pastel Theme (shown above)

  • WCAG AA compliant contrast ratios
  • Soft, easy on the eyes
  • Good for long documents
  • Professional appearance

High Contrast Theme

/* Higher contrast for accessibility */
background: #dbeafe;
color: #1e3a8a; /* Blue */
background: #dcfce7;
color: #166534; /* Green */
background: #fef3c7;
color: #92400e; /* Yellow */

Dark Mode Theme

/* Dark mode optimized colors */
background: #1e3a8a;
color: #e0e7ff; /* Blue */
background: #14532d;
color: #dcfce7; /* Green */
background: #92400e;
color: #fef3c7; /* Yellow */

Monochrome Theme

/* Grayscale with accent */
background: #f8fafc;
color: #334155; /* Light gray */
background: #e2e8f0;
color: #1e293b; /* Medium gray */
border-left: 5px solid #0f172a; /* Dark accent */

Conclusion

Color-coded markdown transforms plain text into visually organized, scannable documents. It's particularly powerful for:

  • LLM-generated content that needs structure
  • Technical documentation with multiple content types
  • Educational materials with different learning objectives
  • Project documentation with various stakeholders

Start with a simple 3-color system and expand as needed. Remember: the goal is clarity, not decoration!


This document demonstrates the power of color in markdown. Use it wisely to enhance, not overwhelm, your content.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment