0% found this document useful (0 votes)
5 views2 pages

Text Color Codes

The document provides a guide on using color codes for text and background in console applications. It includes both Windows Console color codes (0-31 for text and background) and ANSI color codes for terminal text formatting. Additionally, it specifies codes for basic colors, bold colors, and background colors, along with a reset code for default terminal color.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Text Color Codes

The document provides a guide on using color codes for text and background in console applications. It includes both Windows Console color codes (0-31 for text and background) and ANSI color codes for terminal text formatting. Additionally, it specifies codes for basic colors, bold colors, and background colors, along with a reset code for default terminal color.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

For SetConsoleTextAttribute(GetStdHandle(STD_OUTPUT_HANDLE), color);

Text Color Codes (0 to 15):

Code Color Code Color Code Color Code Color


0 Black 1 Blue 2 Green 3 Aqua
4 Red 5 Purple 6 Yellow 7 White
8 Gray 9 Bright Blue 10 Bright Green 11 Bright Aqua
12 Bright Red 13 Bright Purple 14 Bright Yellow 15 Bright White

Background Color Codes (16 to 31):

To set a background color, you simply add 16 to the text color code.

Background Background Background Background


Code Code Code Code
Color Color Color Color
16 Black 17 Blue 18 Green 19 Aqua
20 Red 21 Purple 22 Yellow 23 White
24 Gray 25 Bright Blue 26 Bright Green 27 Bright Aqua
28 Bright Red 29 Bright Purple 30 Bright Yellow 31 Bright White

Here are the ANSI color codes you can use to color text in a terminal:

Basic Colors:

 1. Black: \033[0;30m
 2. Red: \033[0;31m
 3. Green: \033[0;32m
 4. Yellow: \033[0;33m
 5. Blue: \033[0;34m
 6. Magenta: \033[0;35m
 7. Cyan: \033[0;36m
 8. White: \033[0;37m

Bold Colors (Brighter versions):

 9. Bold Black: \033[1;30m


 10. Bold Red: \033[1;31m
 11. Bold Green: \033[1;32m
 12. Bold Yellow: \033[1;33m
 13. Bold Blue: \033[1;34m
 14. Bold Magenta: \033[1;35m
 15. Bold Cyan: \033[1;36m
 16. Bold White: \033[1;37m

Background Colors:

 17. Black Background: \033[40m


 18. Red Background: \033[41m
 19. Green Background: \033[42m
 20. Yellow Background: \033[43m
 21. Blue Background: \033[44m
 22. Magenta Background: \033[45m
 23. Cyan Background: \033[46m
 24. White Background: \033[47m

Reset Color:

 0. Reset (to default terminal color): \033[0m

You might also like