Let's explore these concerns. But first, a question that will seem silly at first.
Does my car even have a gas cap?
Open up the fuel door, and in some newer vehicles there might not be a gas cap at all. Don't panic. While leaving the gas cap off a car that is supposed to have a gas cap might cause issues, this entire discussion doesn't apply to those vehicles that don't have one to start with. Many Ford and some GM products, among others, have capless systems. They look a bit different; see below.
If your gas filler neck looks like this, you don't have to worry about this issue. Everyone else, read on.
Can leaving the gas cap off harm my car?
No, aside from an annoying check engine light from a false EVAP System failure code.
Why can the absence of a simple gas cap cause the check engine light to illuminate?
The fuel system in your car is a sealed system that traps harmful gas fumes. If the gas cap is left off gas is able to escape from the system. When this happens, a self-test of the performance system detects this "leak" in the EVAP (Evaporative Emissions System) and the check engine light comes on, and a code is stored.
Can I fix this myself or do I have to go to a shop to fix it?
Assuming that the check engine light is directly due to the missing gas cap and not some other reason, simply replacing the gas cap and driving the vehicle for 100 miles or so will allow the system to reset itself. If this doesn't work and the light stays on, then there are other complications; the system should be scanned and the problem diagnosed. If you're not sure why the check engine light is on, or whether it's related to the gas cap you just replaced, get the car's computer scanned. You can borrow a scan tool at most auto parts stores for free and then look up the code(s) online, or your trusted mechanic might be able to do it for a nominal fee.
If the gas cap is left off, can the gas leak out of the tank and cause a problem? Is this dangerous?
No. A flapper valve is built into today's fuel filling systems. This valve stops reverse flow of fuel out of the tank. If you stood the vehicle on its head, gas would not flow out of the tank because the flapper valve is an anti-roll valve. So it's not dangerous to leave the gas cap off. However, you will be able to smell gas fumes. And I suppose, if you were mindless enough to stick your head close to the open gas tank filler-neck with a lit cigarette and provide an ignition source for the escaping fumes, you could be compromising your health.
Where do I buy a new gas cap?
I would buy an OEM (Original Equipment Manufacturer) gas cap because it will always thread correctly into the filler neck, the seal will seal properly, the proper vent valves will be in place and the cap will be designed specifically for your vehicle's fuel system. Deviate from OEM design and you are asking for trouble. To be safe, call your local vehicle dealer and ask for the part number, and either buy it from a reputable online parts store or from the dealer parts department.