Pi HDMI Not Functioning
A common pitfall with the Raspberry Pi board is that the display connected to the HDMI port must be connected and powered before booting the Raspberry Pi. Otherwise, the HDMI output will not be activated. Take special care to ensure the HDMI connector is physically inserted all the way into the Pi, especially with the new Micro HDMI connectors on the Raspberry Pi Model 4B.
I'm using NOOBS or NOOBS Recovery and only see a rainbow:
If you are using NOOBS or NOOBS Recovery and are only seeing a rainbow on your display, please ensure you are using the HDMI0 connector (closest to the Power connector). At this time, NOOBS/Recovery only supports HDMI0 for starting. After, the OS selected will work with both displays (if supported by the OS).
My display stays black:
If your display is plugged in and powered before powering the Pi but stays black, you can try the following code to ensure that the HDMI output always activates (whether the monitor is detected or not) by adding the following lines of code to the config.txt file of the operating system on the microSD card, using any computer with a microSD card reader:
For Rasberry Pi models up to and including Pi3
For Raspberry Pi 4 models with dual HDMI
Note: Because the Raspberry Pi 4B has two HDMI ports, some HDMI commands can be applied to either port. You can use the syntax <command>:<port>, where <port> is either 0 or 1, to specify which port the setting should apply to. If no port is specified, the default is 0. If you specify a port number on a command that doesn't require one, the port is ignored.
Note: On Pi 4s, there's an issue with displays using 1366x768 resolution (reference). The solution is to use another resolution, see here: STICKY: Setting up HDMI output when video output is wrong.
More details here: Raspberry Pi documentation - HDMI configuration and here: Raspberry Pi documentation - Video options in config.txt