I want to use an LM311 comparator to compare my 12V battery voltage to some reference I have, but I want it to output 5V so I can read it with my microcontroller. Due to this, I'd think I have to set the V+ pin to 5V. If I do this, can I still input 12V to it?
The LM311 is not very good to power with just 5V as it will have a very restricted input range (only 0.5V to 3.5V when powered from 5V) I would power the VCC+ from a 12V supply (possibly the voltage you are measuring if appropriate). A more modern comparator would not have this restriction - even an LM393 which is 40 years old would be better.
The output is open collector so you can use a pull-up resistor to 5V to produce a 5V logic signal even if powering it off 12V.
The allowable input range is only up to (VCC+) - 1.5V, which is 10.5V if the supply is 12V so you cannot put the 12V you wish to measure directly into the IN+ pin. You will need a divider to bring it below 10.5V even when the 12v level is at it's highest (for example if it could be 15V then divide it so the input voltage is 10.5V under that condition).