President Reagan and Democratic congressional leaders failed yesterday to agree on terms for a tax bill, but both sides said that the opportunity still exists for compromise.

Both Reagan, who wants a three-year, across-the-board tax cut, and the Democratic leadership, which wants a one-year reduction aimed more heavily at middle-income taxpayers, held their ground in a White House summit meeting yesterday.

Afterward, House Speaker Thomas P. (Tip) O'Neill Jr. (D-Mass.) denounced the Reagan plan as "a windfall for the rich," and Treasury Secretary Donald T. Regan drily characterized the meeting between the president and the Democrats as "lengthy."

Nonetheless, Regan and House Ways and Means Committee Chairman Dan Rostenkowski (D-Ill.) held out the promise of at least one more attempt at compromise later this week. Disagreeing with O'Neill, Rostenkowski said that the president had made some concessions and that the door was still open to an agreement.

On the other hand, high administration officials warned that if such an agreement does not come this week, the president will proceed with a two-part plan, working to rally conservative Democrats in the House while asking the GOP-controlled Senate Finance Committee to immediately begin action on the Reagan bill.

The conservative House Democrats, who provided the administration with its margin of victory on the budget, are expected to meet this afternoon to consider their own strategy. Sources said their inclinations on the tax bill are similar to the administration's.

The maneuvering on taxes came as Reagan's budget director, David A. Stockman, also sought to keep Democrats from wiggling out of the budget in votes Congress will take in the next several weeks cutting specific programs. He said Congress would be guilty of "deliberate sabotage" if, as O'Neill and some others hope, it refuses to make the program cuts.

Rostenkowski is scheduled to convene another caucus of Ways and Means Democrats today to consider the majority party's next step in dealing with a president who remains adamant about the principal features of his tax bill.

The Ways and Means chairman told reporters after the White House meeting he would "like to think that" a compromise still is likely, saying that "the fact that there are [only] two areas of disagreement gives me hope."

Rostenkowski said later, however, that Democrats do not intend to respond with a new counter-offer. "If we draw up a package, we'll draw up a package in the Ways and Means Committee," he said.

Also trying to strike a conciliatory note, Regan said, "The door is open and they have promised to come back to us" with a response on the proposal. But the treasury secretary cautioned that Reagan is not going to retreat on his basic plan.

"The president wants -- and is sticking by -- multi-year, three-year tax cuts, across the board," said Reagan at a White House briefing after the meeting. "He thinks he needs these things. He was elected on this basis and it's a matter of principle for him."

At the same time, the president gave his blessing to concessions on other issues that had been previously been negotiated by Reagan, including cutting to 5 percent the first of his three proposed 10 percent-a-year tax cuts and adding in several key provisions previously sought by Democrats.

These would include:

Reducing the "marriage penalty" under which couples filing jointly often pay higher taxes then they would if filing singly.

Slashing the maximum tax rate on investment income to 50 percent from the current 70 percent.

Cutting estate and gift taxes.

Liberalizing tax incentives for retirement savings.

Increasing the "zero bracket amount, which replaced the personal exemption allowed to all taxpayers and their families.

Enacting new tax credits to spur research and development.

After a two-hour meeting in the Oval Office with the president, the Democratic leaders emerged in the rain outside the White House where O'Neill described the session as "more of a media event than anything else."

During the day, both sides attempted to turn the "media event" to their advantage by defending their positions while at the same time saying they were open to a reasonable compromise.

However, as in the budget battle of a few weeks ago, the Democrats appeared to be divided on strategy, with O'Neill seeming to differ sharply with Rostenkowski and House Majority Leader James C. Wright Jr. (D-Tex.), who seemed to be operating on his own wavelength. Participants in the White House meeting said Wright proposed a three-year tax cut of only 5 percent a year, a plan that won no immediate backing from anyone.

Senate Democrats also had their own ideas. Sen. Russell B. Long (D-La.), ranking minority member of the Senate Finance Committee, told the president that he thought a three-year bill would pass the Senate if only because enough members want to tack on their own pet proposals.

Yesterday, Finance Committee Chairman Robert J. Dole (R-Kan.) underscored the view that, for all the disagreement, a compromise remains possible.

"There's still enough elbow room to justify pursuit of a compromise tax package with, House Democrats," he said.