NEW YORK — With backyard barbecues and fireworks, Americans celebrated Independence Day by participating in time-honored traditions that express pride in their country’s 242nd birthday.
But the quintessential American holiday was also marked by some with a sense of a United States divided, with a debate raging about immigration policies and competing observances staged in the nation’s capital.
From New York to California, July Fourth festivities were at times lively and lighthearted. They were also stately and traditional, with parades lining streets of many cities and gun salutes fired to mark the 242 years since the signing of the Declaration of Independence.
In Colorado, the wildfire danger forced some communities to cancel their July Fourth fireworks. However, other shows were to go ahead as planned in Denver, Colorado Springs, and Fort Collins.
Some communities with high wildfire risks in the West offered light displays instead of pyrotechnics.
President Trump tweeted a military-themed Independence Day video greeting to the nation. In a short recording, Trump said Wednesday he and first lady Melania Trump wished everyone a happy holiday.
Trump focused on service members and veterans. ‘‘Our freedom has been earned through the blood and sweat and sacrifice of American heroes,’’ he declared. “And these are great American heroes.’’
Trump held a picnic Wednesday afternoon for military families at the White House, followed by a concert and with a view of the National Park Service’s fireworks display.
Many people got to call themselves US citizens for the first time Wednesday, after participating in naturalization ceremonies across the country.
Some people lamented that the country’s ability to debate the tough issues of the day civilly seems hopelessly lost.
For Brad Messier, a chef in Portland, Maine, the holiday ‘‘seems to illustrate the glaring divides that we have.’’
‘‘How much does going and seeing fireworks really bring people together?’’ he asked.
Two men died and five other people were injured after a large tree branch fell on spectators during a fireworks display in western Illinois late Tuesday. Rock Island County sheriff’s officials said dozens of people were sitting near the tree at the time.
In Maryland, a 21-year-old man was hospitalized with ‘‘catastrophic injuries’’ to both hands after setting off fireworks at a large outdoor party where several attendees brought illegal fireworks, according to investigators. They said the man’s injuries weren’t life-threatening.
The country’s longest-running live national July Fourth television tradition is the PBS broadcast of music and fireworks from the US Capitol’s West Lawn.
But it faced counterprogramming this year from the White House, which hosted its own concert and view of the National Park Service’s fireworks show.
PBS’s ‘‘A Capitol Fourth’’ had the bigger stars, including Chita Rivera, The Beach Boys, Jimmy Buffett, Pentatonix, Luke Combs, and The Temptations. It was hosted by John Stamos.
The entertainers for the 90-minute White House event, aired on the Hallmark Channel, included singer-songwriter Sara Evans, pianist Lola Astanova, and two former ‘‘American Idol’’ finalists.
In New York, Macy’s offered 25 minutes of fireworks over the East River, plus the West Point Band and entertainers including Kelly Clarkson, Ricky Martin, and Keith Urban on NBC’s broadcast.
In Annapolis, Md., staff members from the newspaper where five employees were shot to death took part in the Fourth of July parade.
Mayor Gavin Buckley said the city invited journalists from The Capital Gazette to participate in the parade Wednesday evening.
The mayor said he hoped the gesture would help the city heal from the tragedy.
The newspaper staffers were given a place of honor near the front of the parade.