WASHINGTON — Bipartisanship and cross-party alliances are suddenly in vogue in the Senate this spring. The question is whether the Senate is a leading indicator of a change in politics or largely an aberration in a nation divided along red and blue lines.

On guns and immigration, senators from both parties have worked for months to craft legislative compromises. A guns bill began its journey Thursday after the Senate invoked cloture, but its future is uncertain. A compromise immigration bill could be unveiled this week, with growing optimism that Congress will approve a comprehensive reform measure this year, though it faces an equally difficult debate, particularly in the House.

Meanwhile, senators from both parties are looking for ways to break the gridlock over the deficit and fiscal issues. President Obama’s dinners with Republican senators are aimed in part at helping nurture such a compromise, though there are few signs of an imminent breakthrough on a problem that has defied a solution for almost the entirety of Obama’s presidency.

All of that represents progress after four years of confrontation, conflict and stalemate. Certainly the 2012 election played some role in changing the climate in Washington, particularly on immigration. The Republican deficit among Hispanic voters in particular has helped change the politics on that issue.

But for all the hopeful signs in Washington, there is considerable evidence that the country is still deeply divided, ideologically and geographically. Those divisions, which will show up when these volatile issues hit the House floor later this year, could stymie Washington’s ability to pass laws to manage some of these problems. The splits also will continue to shape the elections of 2014 and 2016.

The 2012 elections may have provided a wake-up call for Republicans on issues such as immigration, alerting GOP leaders to the general problems they face in presidential races. But the results also highlighted the degree to which the country’s partisan gaps keep widening — to the detriment and benefit of each party.

Obama defeated Mitt Romney by a margin of about 4 percentage points, hardly close to a landslide. But the state-by-state votes tell another story. Only a few presidential cycles ago, the competitive landscape was thought to include about 16 states. Last November, the number of truly competitive states was as small as anyone could remember in a competitive election — fewer than 10 certainly.

In the end, just four states — Florida, Ohio, Virginia and North Carolina — were decided by margins of 5 points or fewer. But 28 states were decided by margins of 15 percentage points or more. For comparison purposes, go back to the 1988 election, which George H.W. Bush won by a margin of about 8 points. In that election, 12 states were decided by 5 or fewer points, while only 18 were decided by 15 points or more.

Bill Bishop and Robert Cushing, who wrote “The Big Sort: Why the Clustering of Like-Minded America is Tearing Us Apart,” have estimated the percentage of the population that lives in what they call landslide counties, where the winner’s margin in presidential elections is 20 points or more. In 1976, about a quarter of the U.S. population lived in these landslide counties, but the number has grown steadily since. In 2012, just over half the population resided in landslide counties.

County-by-county voting patterns have hardened over time. There are more than 3,000 counties in the country. Between 2004 and 2008, just 382 counties changed from one party to the other in the presidential vote. Last November, just over 200 counties switched parties.

These kinds of schisms not only affect presidential voting patterns but also the structure of the House of Representatives. Charlie Cook’s authoritative Cook Political Report, with the assistance of Clark Bensen of Polidata, has done a fresh ranking of House districts and found, not surprisingly, that the number of swing districts has declined by about 45 percent in the past quarter-century, from 164 to 90.

As the parties have become more homogenized, and as split-ticket voting has declined, House districts align more closely to presidential voting patterns. In today’s House, there are just 17 districts that were won by Obama in Republican hands. Conversely, just nine districts won by Romney are held by the Democrats.

The Cook Report’s David Wasserman noted that, despite the fact that the presidential race was closer in 2012 than in 2008, three-quarters of Democratic House districts became more Democratic and three-fifths of Republican districts became more Republican.

Rhodes Cook, an independent analyst of elections, said recently that Democrats are now the presidential party while Republicans are the congressional party — the opposite of the situation during the 1970s and 1980s.

Democrats now hold a clear advantage in the Electoral College, with 18 states and Washington having voted for the Democratic nominee in six consecutive elections. Together they total 242 electoral votes, only 28 short of the 270 needed to win the presidency.

Republicans, however, have the advantage in the House, thanks to the shape of the districts. Republicans lost the popular vote in the House last fall but kept control of the chamber. That advantage is due to a combination of the effects of redistricting and the general geographic sorting out that has been taking place.

These geographic patterns influence what is happening in the states. Many more states now have governors and legislatures held by the same party, with Republicans controlling more states than Democrats. These governors and legislatures in red and blue states are moving in opposite directions, as a new article in the National Journal by Ronald Brownstein and Stephanie Czekalinski points out.

While the Maryland legislature under Gov. Martin O’Malley, a Democrat, has moved left on guns, taxes and the death penalty, state legislatures where Republicans are in control, such as Louisiana, North Dakota and Kansas, have moved right on fiscal and social issues. North Dakota recently passed the most restrictive abortion law in the country.

It’s possible that the work in the Senate this spring shows a softening of the rigid lines that have shaped politics over the past decade. At the least, there is a greater bipartisan desire to try to deal with some long-standing issues. If the president and House Speaker John Boehner, R-Ohio, can reach agreement on a fiscal package to deal with the deficit, that would be the biggest breakthrough of all.

But the reality is that these other factors are still pushing the country apart. The current divisions have been years in the making. Whether Washington politicians can — or truly want to — do something to narrow them is what this year is all about.