When setting the database OFFLINE, the database is shut down, and can not be modified during this state. Since the database is unavailable, request to database returns error. When the database is set ONLINE, the database is open and available to be use.
To take the database base OFFLINE,
Using SQL Server Management Studio (SSMS),
Right click the database > Tasks > Take Offline
ALTER DATABASE YourDatabase SET OFFLINE WITH ROLLBACK IMMEDIATE;
The rollback immediate is an option if you wish to immediately rollback all active transactions before taking the database offline.
To bring the database ONLINE,
Right click on the database > Tasks > Bring Online
USE master; ALTER DATABASE YourDatabase SET ONLINE;
To view the database current state.
Right click on the database > Properties > Status. (When the database is offline, there is a red color down arrow overlay as indication. You may also right click the database and click refresh to update its current status)
USE master; SELECT name, state, state_desc FROM sys.databases WHERE name = 'YourDatabase';
There is also another option DETACH and ATTACH. Here is the blog about if you should use OFFLINE or DETACH.