Since version 3.0, Safari has provided Reopen Last Closed Window and Reopen All Windows From Last Session commands in its History menu, which let you reopen your last Safari windows and restore any tabs that were open within them.
But what about the single tab you closed accidentally? The one you opened a while ago, so it’s not easy to find in your history? Safari hasn’t provided an easy way to resurrect it – until now. This is an (apparently undocumented) feature in Safari 5: if you accidentally close a tab you didn’t mean to close, press Command-Z (you can also select Edit > Undo). The lost tab will be immediately restored – in fact, this will open the last tab closed in each window.