How to change font color in html output on C++ ?

Asked By 0 points N/A Posted on -
qa-featured

Hi,

I need help with my assignment. Basically I have to make an html page and have the output display in a .cgi file.

I am able to change the font and colors in the html page but the output of my CGI file comes out in black font.

I was wondering if anyone knew how to change the color of the font in the output displayed?

SHARE
Best Answer by telord
Answered By 0 points N/A #114913

How to change font color in html output on C++ ?

qa-featured

Hi Henry, regarding to your problem on how to change the text background color and text is simple like this.

#include<iostream.h>
#include<conio.h>
#include<dos.h>
main()
{
    textbackgroundcolor(BLUE);
    textcolor(YELLOW);
    
     clrscr();
     cout<<"/n/n/t/t/t HENRY";
    
      getch();
      return 0;
}

> if you want to make your text to blink. just add to the code which is textcolor(YELLOW+BLINK);

ok? just try..

*edit: next time please use code tags – 1lacca

Best Answer
Best Answer
Answered By 30 points N/A #114915

How to change font color in html output on C++ ?

qa-featured

HelloHenry,

This might help you.
  • In C++ form

    #include <stdio.h>

    #include <windows.h> (dont forget to put this)

    system("color #"); (colors range to 0-15)

    HANDLE hColor;

    hColor=GetStdHandle (STD_OUTPUT_ HANDLE);

    SetConsoleTextattribute(hColor, #);

    pick a code:

    Code:
    #define black 0
    #define dark_blue 1
    #define green 2
    #define cyan 3
    #define red 4
    #define dark_purple 5
    #define brown 6
    #define gray 7
    #define dark_gray 8
    #define blue 9
    #define neon_green 10
    #define light_blue 11
    #define light_red 12
    #define purple 13
    #define yellow 14
    #define white 15
     
    For foreground and background:
  • SetConsoleTextAttribute (hOut, BACKGROUND_BLACK);

    The background will be black,

    SetConsoleTextAttribute(hOut, BACKGROUND_BLACK| FOREGROUND_RED);

    Background Black then font will be red.

    Here's the Attribute Meaning:

    FOREGROUND_BLUE Text color contains blue.
    FOREGROUND_GREEN Text color contains green.
    FOREGROUND_RED Text color contains red.
    FOREGROUND_INTENSITY Text color is intensified.
    BACKGROUND_BLUE Background color contains blue.
    BACKGROUND_GREEN Background color contains green.
    BACKGROUND_RED Background color contains red.

 

Related Questions