It could soon cost you $300 if you aren’t wearing a face mask in public in the city of Somerville.

Beginning Wednesday, face masks — or other appropriate face coverings that cover the nose and mouth — are mandatory in all public spaces in the city, outdoors and inside. Scarves, bandanas, or any piece of clean cloth may also be used.

The measure was announced Monday by Mayor Joe Curtatone and the city’s board of health after garnering unanimous support from the city council.

“Wearing a mask is far more effective if everyone is doing it,” said City Council President Matt McLaughlin in a statement from the city. “The effectiveness of face masks decreases significantly if someone infected with COVID-19 isn’t wearing a mask, even if others do wear masks.”

After a week-long grace period, people who do not comply with the order could face a $300 penalty.

“Ticketing for this is our last resort, but we do have to put public health first. So for those individuals who willfully fail to comply, we will reserve this option,” said Chief of Police David Fallon in a statement.

Somerville is the most densely populated city in New England, with more than 80,000 residents in a 4.1 square mile area. To date, 522 residents in the city have tested positive for COVID-19, with six confirmed fatalities.