An integral part of many fiction pieces is dialogue, or the actual spoken words of the characters. Passages in fiction are often indicated as dialogue by quotation marks (" ") and tell the reader that a character is speaking. Dialogue plays a crucial role in fictional works and can serve to function as more than just simple banter between characters.
Dialogue must be between two or more characters. When one character speaks to himself, it is known as a monologue, which can also be indicated by quotation marks. Dialogue can reveal to the reader a number of things about particular characters, and can be particularly revealing when compared to their inner thoughts or their actions throughout the piece of fiction. In fact, some authors will write most, if not all, of their piece as one long dialogue. Plato is notable for this technique.
Dialogue is, of course not only limited to fiction. It can appear in non-fiction, essay, poetry, news articles, etc., but in fiction, it serves a purpose beyond simply relaying what a particular character says. Dialogue can reveal hostilities between characters; it can reveal subtext, or emotions and ideas not explicitly expressed in the prose; and it can give the reader a clue as to where the character might be from, what their life is like, what their education level might be, etc. It can also give the reader an idea of whether or not a narrator is reliable, assuming the narrator is one of the participants in the dialogue.
Authors will often use excerpts of dialogue to clue the reader in to certain ironies -- most notably verbal irony, in which a character says one thing but really means something else. Depending on what mood the author is trying to convey, they may choose to write their dialogue as a quick back-and-forth style, or as a slower, more deliberate exchange. In order to slow down the pace and also to make sure the reader can keep track of who is speaking, writers will include tags at the end of certain lines, such as "he said," or "she asked." Tags may also appear at the beginning or in the middle of lines of dialogue, but they most commonly appear at the end.
Lines of dialogue are most commonly broken up onto separate lines to further distinguish who is speaking. Here is a short example of dialogue broken up onto separate lines, and also using tags:
"Where are you going?" Bill asked.
"To the grocery store," Shelly said.
"Can you pick up some orange juice for me?"
"Yes," Shelly said, "I can."