House Democratic Leader Nancy Pelosi (D-Calif.) speaks during a news conference at the U.S. Capitol August 11. Also pictured (L-R) are Rep. André Carson (D-Ind.) and Rep. Steve Israel (D-N. Y). (Win McNamee/Getty Images)

The House of Representatives wasn’t in play in 2016, but that shouldn’t be news to you. Whatever my failings in assessing the presidential race, my view that Democrats never had a chance to flip the House proved generally correct.

After seeing a comment from House Leader Nancy Pelosi and a flurry of pieces in the late summer and fall suggesting that the House was suddenly “in play,” I wrote on September 22nd that Democratic chances of winning 30 seats ranged somewhere between “slim and none.” About a month later, on October 25th, I reiterated that assessment.

The combination of few competitive districts, polls in individual districts showing Republicans well positioned, and the Democrats’ narrow advantage in the national “generic ballot test” made it clear throughout September and October that the House would not flip without a dramatic, last-minute shift in public opinion. That shift, of course, never occurred, and Donald Trump’s victory further limited Democratic congressional gains to a mere six seats.

Those small gains mean that Democrats will need to net 24 seats in 2018 to take back the House, a daunting task considering the small number of Republicans sitting in Democratic districts and the paucity of competitive districts.

First, let’s start with the good news for Democrats — since they need some good news.

The party not holding the White House has gained seats in 18 of the past 20 midterm elections. That trend isn’t a mere coincidence. It follows from the fact that a midterm is almost always a referendum on the incumbent president — and the most disappointed and dissatisfied voters tend to turn out during midterms to send their message of disapproval about the president and his party.

Over the past 20 midterm elections, going back to 1938, the out-party has won at least 24 seats a substantial 11 times. That too gives Democrats a glimmer of hope about 2018.

Democrats also have reason not to be dispirited by the argument that midterm electorates tend to be older and whiter (along with being more upscale) — and therefore more Republican — than presidential electorates.

That description of the midterm electorate is certainly true, but it doesn’t mean that a midterm election can’t deliver a resounding victory for Democrats. House Democrats won only 46.8 percent of the popular vote, and just 202 seats, in 2004, a presidential year. But two years later, during Republican Pres. George W. Bush’s second midterm election, Democrats won 52.3 percent of the popular vote and 233 seats.

On the surface, the 2006 midterm electorate appeared more favorable for the GOP than the 2004 electorate. The exit poll showed there were more white voters in 2006, more white men, fewer younger voters and fewer union members. And yet, Democrats flipped the House that year.

The reason is simple. The 2006 election became a referendum on an unpopular president, so even though the electorate profiled as more Republican, voters across most demographic categories voted more Democratic than they had just two years earlier.

In 2004, President George W. Bush (48 percent) and challenger John F. Kerry (49 percent) virtually split self-described Independent voters. But two years later, Independents voted heavily for Democratic House candidates over GOP House candidates, 57 percent to 39 percent.

So, while turnout profiles of the parties and voters suggest a Republican midterm advantage, the 2018 dynamic, with a Republican in the White House, suggests a very different outcome is likely.

But while there are reasons for Democratic optimism about the 2018 fight for the House, Republicans have an ace in the hole: the small number of competitive districts.

In the next Congress, there will be fewer than two dozen House Republicans sitting in congressional districts won by Barack Obama in 2012. That means Democrats will need to swipe at least a handful of districts carried by Mitt Romney four years ago to win control, and that is a huge, uphill fight for the Democratic Congressional Campaign Committee.

Moreover, many GOP representatives in Obama 2012 districts have proven their metal. Republican House members like Erik Paulsen (Minn.), Tom MacArthur (N.J.), Mike Coffman (Colo.) and Dave Reichert (Wash.) have shown their fundraising strength and electoral appeal. Republican John Katko, who represents a very Democratic district in Upstate New York, crushed his Democratic challenger by more than 20 points last month, a testament to his political savvy.

Sure, there are a few Republicans who look like juicy targets in 2018, including Jason Lewis in Minnesota’s 2nd District, Rod Blum in Iowa’s 1st District and possibly David Valadeo in California’s 21st C.D. But all three won in 2016, and Democrats can’t merely assume that they will fall in two years.

Moreover, House Democrats could see a stampede out of the door of incumbents who find state office or the private sector more appealing that four years of Donald Trump in the White House.

Obviously, the outlook for the House in 2018 depends on many factors, including Democratic recruiting and the two parties’ fundraising. But the most important factor by far is how well Donald Trump performs in the White House and how satisfied or dissatisfied voters are when the 2018 midterm balloting rolls around.

Stuart Rothenberg writes about the politics of the presidential and congressional races.

Read more on Power Post