HTML CSS works in one file but not another

I'm new to HTML and CSS and encountering a baffling problem. I created a very simple HTML file and then attempted to add some CSS to it. I could not get an external style sheet to work so I tried entering it internally. I got this to work but only with basic element selectors (it will not work with any id selectors). I was sure I was entering everything correctly though so I copied and pasted this example into a new html file. The example it worked as it should. So then I opened a new file and typed directly what was in the example into the new file myself word-for-word, and it doesn't work! I've gone over it countless times and there are no typos. What could possibly be causing this?