Facebook has taken the unusual step of shutting down ads for an entire nation.

The social network said it has turned off ads in Thailand following the death of the country's deeply revered king. It's the first time Facebook has imposed an ad blackout for a whole country.

King Bhumibol Adulyadej's 70-year reign came to an end on Thursday when he died at the age of 88. Facebook (FB) said in a post that removing ads is "a cultural custom" during the mourning period.

It admitted that it doesn't yet know how long Thailand will be mourning the king, whose unifying appeal stretched across Thai society.

Related: Thai economy could stall after King's death

According to the royal palace, all government buildings will fly the national flag at half-staff for 30 days starting Friday, and all civil servants have been ordered to wear black clothing for a year.

Facebook declined to comment further on the ad shutdown. Its post said advertisers within Thailand can still run ads outside the country.

Other websites took measures to reflect the country's somber mood. Google (GOOGL)'s homepage in Thailand was changed to a dark-gray-and-white color scheme, although ads were still showing up for some searches.

Related: The life of the Thai king

The Bangkok Post, a leading English-language newspaper, also made its homepage completely monochrome. The only ads it carried were for its own services, like newspaper subscriptions. For much of Friday, Thai TV stations broadcast solely in black and white.

Facebook's move to switch off ads isn't the first time a major global Internet company has taken such a step out of respect. Yahoo (YHOO) turned off ads and went to black and white on its front page in Singapore following the death last year of the city state's founder, Lee Kuan Yew.

-- Karla Cripps and Marc Lourdes contributed to this report.