1. When to use a comma:
* When "while" introduces a dependent clause: This means the clause with "while" can't stand alone as a complete sentence.
* Example: "I was reading a book, while the sun set." (The clause "while the sun set" needs the first part to make sense.)
* When "while" introduces a contrasting idea: This is similar to using "but" or "although."
* Example: "The weather was cold, while the sun was shining." (The cold weather and the sun shining are contrasting ideas.)
2. When NOT to use a comma:
* When "while" acts as a conjunction: This means it joins two clauses that could stand alone as sentences.
* Example: "I went to the store while you were at work." (Both "I went to the store" and "you were at work" can be sentences on their own.)
Important Note:
There are some cases where grammar rules might differ slightly depending on style guides. Always check the style guide you are using if you are unsure.