It can be hard to place all those commas and periods in the dialogue bits. At the same time, you need to think of capitalization. When to capitalize and when not? Where goes what and why?
Here are two examples of the capitalization.
1. "Where are you?" Asked Mary.
2. "Where are you?" asked Mary.
Which one is right? Yes, it's number two. Even though Mary's line ends with a question mark – which would usually mean that the next sentence should be capitalized – the next letter after the quote remains lower case. Unless the quote is followed by a proper noun, as in:
"Where are you?" Mary asked.
Then for some punctuation.
1. "I'm here," the squirrel replied.
2. "I'm here", the squirrel replied. New!
3. "I'm here!" the squirrel replied.
4. "I'm here." The squirrel replied.
In this case, 1, 2, and 3 are correct. Number 4 is wrong in the same way than number 1 in the previous example.
New! What about the commas 1 and 2? Why are both correct? You might have learnt it as 1, you might have learnt it as 2, or you might have learnt it as neither and be very confused.
Number 1 (placing the comma inside the quotation marks) is the "American" way of doing it, and number 2 (comma outside the quotation marks) is the "British" way. I learnt it as 2, and after I joined YWS, I saw many more people doing it as 1, so I decided to conform and gradually switched to 1 as well. However, I've since switched back to 2 since I just like it better. I suggest you stick to the style you've learnt, because as you see, both are correct and no one can complain about your decision.
You can also start with a speech tag:
Mary asked, "Where are you?"
Mary asked: "Where are you?"
Both examples would be correct.
But what if the speech tag is in the middle of quotes?
1. "I'm coming," said Joan, "don't be so impatient."
2. "I'm coming," said Joan. "Don't be so impatient."
Funnily enough, both of these are correct. Note that in number 1, the first letter of the second quote is not capitalized, because there's a comma after 'Joan'. If we take 'said Joan,' away, the line would be:
"I'm coming, don't be so impatient." As you can see, there's only one sentence. And we wouldn't capitalize the 'don't' now, would we?
Whereas number 2 has a period after 'said Joan', and without this speech tag, we would have:
"I'm coming. Don't be so impatient." Now there are two sentences! It's almost like magic!
They look different, but they're still both right!
Also, you don't always have to have the speech tag before/after the quote.
1. Mary looked frantically around. "Where are you?"
2. "I'm here." The squirrel frowned in frustration; he had gotten enough of Mary's paranoia.
As you must have noticed, without the speech tag it's completely correct to capitalize the first letter after the quote.
Well, I hope this has given you a basic idea about the punctuation in dialogue. Have a good day!