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>This document demonstrates how to use colors in markdown to create visual hierarchy and make content more scannable, especially when LLMs generate documentation.
- 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
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
- Core Concepts
- Important Notes
- Advanced Techniques
- Critical Information
- Best Practices & Tips
- Implementation Examples
- Color Scheme Variations
- Conclusion
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
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 gradientpadding: Internal spacingborder-radius: Rounded cornersborder-left: Accent stripemargin: External spacing
Supported Platforms:
- β GitHub (with some limitations)
- β GitLab
- β Most documentation sites
- β Many markdown editors
- β Plain text viewers
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); }
Use CSS gradients for more sophisticated looks:
background: linear-gradient(135deg, #color1 0%, #color2 100%);
You can nest colored sections for sub-categories:
Sub-section Example This creates a layered effect with transparency.
Consider mobile viewing:
@media (max-width: 768px) { .colored-section { padding: 15px; } }
- Overuse: Too many colors can be overwhelming
- Accessibility: Ensure sufficient contrast ratios
- Consistency: Stick to your color scheme
- Performance: Inline CSS can bloat large documents
- 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
- Start Simple: Begin with 3-4 colors maximum
- Use Icons: Combine colors with emojis for better recognition
- Test Readability: Ensure text remains legible
- Document Your System: Create a legend like this document
- Be Consistent: Apply the same color to the same content type
- 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
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>
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 */
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.