Rockville Mayor William E. Hanna thought he had a housing idea whose time had come.

But when the Rockville City Council recently considered zoning changes that would allow homeowners to rent out apartments in their single-family houses, it ran into "an absolutely violent reaction from the public."

"People seemed to be afraid of a domino effect," said Hanna. "Once you allowed one house to put in an apartment, the temptation would get to everyone and soon the neighborhood would change from single-family to multifamily houses."

The response, which scotched the proposal, reflected the difficulties communities across the nation face as they struggle increasingly with a scarcity of affordable rental housing and a rise in illegal apartments in single-family homes.

In Fairfax County, zoning officials are drafting a proposal that would legalize such now-banned apartments, with public debate expected sometime early next year.

And some communities, such as Babylon, N.Y., and Weston, Conn., already have dealt with those problems by legalizing such apartments under carefully controlled circumstances.

Other communities have chosen to look the other way while more and more illegal apartments --commonly defined by having an independent kitchen -- are tucked into basements and attics of homes in neighborhoods zoned solely for single-family homes.

The rents for these "accessory apartments" -- $250 to $350 a month isn't uncommon in the Washington area -- help newer homeowners meet their payments. Some urban planners, although they are frequently hotly disputed by neighborhood organizations, argue that such apartments also help inflation-pinched elderly people retain their homes and provide a feeling of security for them.

Zoning authorities contend that the apartments can downgrade residential neighborhoods and create safety and sanitation hazards. However, the U.S. Department of Housing and Urban Development, in a report entitled "The Affordable Community," to be published this month, suggests that they could help meet the demand for rental housing.

Officials in jurisdictions that have legalized the apartments caution that strict controls must be enforced in order to avoid widespread abuses. Typically, such controls require that the homeowner live in the house and that off-street parking be provided for all residents.

"The idea makes sense, especially in a city like Rockville, with so many large houses," Hanna said. "The accessory apartment idea would have the double-barreled effect of helping the elderly owners stay on and providing housing for other people."

Zoning and housing officials in this area say that illegal rental units have existed in some neighborhoods for years, and are not of significant proportions here. However, based on a U.S. Census Bureau estimate of 2.5 million such units built throughout the country during the 1970s, there may be between 20,000 and 30,000 of them here. The spread of these accessory apartments, also known as "undocumented conversions," is being studied by the Metropolitan Washington Council of Governments (COG).

Roger Wentz, who conducts housing studies for COG, said that record low vacancy rates, some near the 1 and 2 percent level, were causing illegal apartments to become increasingly common in this area. He noted that last year the only apartment houses built here were government subsidized for low-income tenants. "There's an increasing demand for rental housing, but no response in supply," Wentz said."

The pressure is heightened by the fracturing of American families into smaller and smaller units requiring more and more places to live, particularly relatively modest apartments. This, according to Arthur F. Young, chief of the Census Bureau's housing division, is a result of the rising divorce rate, the single-parent family, and grown children seeking their own homes at younger ages.

"Young people have nowhere to live and no choice but to ask the in-laws to convert the old two-car garage into an apartment --whether it's legal or illegal," Young said. "This leads to undocumented conversions."

"I can't tell you how many people I know who do it," exclaimed a mother of three young children who rents out a basement apartment in her large, rambling house to two George Washington University students. "Certainly almost every single parent does it. How else could we pay our bills?" She declined the use of her name for fear of calling authorities' attention to herself.

But in general, she and homeowners like her apparently have little reason for such concern. Authorities in this area typically turn a blind eye to illegal apartments, according to area housing and zoning experts.

Whayne Quin, a Washington attorney in a firm specializing in zoning-related cases, said that D.C. authorities, who can impose fines of up to $100 a day and order removal of the offending kitchen, take action on illegal apartments "infrequently." His firm handled two cases in the last year, he said.

In Alexandria, said zoning inspector Richard Josephson, a zoning wrongdoer is subject to both fine and jail. "We've never jailed anyone, but we have fined them," Josephson said. Actually, one in the last two years, he added.

Officials in other area jurisdictions report similar attitudes.

In the absence of any figures from local authorities, a rough estimate -- using the Census Bureau's 2.5 million national figure as a base and adjusting it to reflect the fact that 1/88th of the U.S. population lives in the Washington metropolitan area-- indicates that there would be about 28,000 illegal apartments here, 2 percent of the area's 1.1 million housing units. Independent surveys conducted in several East Coast communities found that an average of 10 to 15 percent of all their housing units are illegal apartments.

Patrick H. Hare, a Washington-based city planner, said that citizens and local politicians, though they recognize the steady growth of such units, are repelled by any attempts to legalize accessory apartments, as much for psychological reasons as any other.

"You can't subdivide the American dream until you have a constituency with that need and at this stage most people don't understand how they'd benefit," Hare said. "Until that happens, there'll be none of the required zoning changes and for any politician to try would be suicide."

Phyllis Santry, senior planner for the New York-New Jersey-Connecticut Tri-State Regional Planning Commission, recently surveyed area political leaders about illegal apartments in their jurisdictions and found that "interestingly enough, the consensus was that it seems to be in everyone's best interest to keep them illegal.

"That way, the owner tends to keep the property up for fear of having his neighbors report him; the owner doesn't have to worry about increased assessments; the politicians don't have to face the hassle of rezoning. Unfortunately, it also results in some pretty ticky-tacky apartments and the town doesn't get to net any increased taxes."

One city that has come to grips with the problem is Babylon, an aging suburb of New York on Long Island's south shore, with a population of 220,000, most of whom are blue-collar workers. According to Babylon planner Richard Spirio, 10 percent of the 37,000 housing units had illegal apartments in them.

"About two years ago, we realized that we had to do something about it or see the situation get out of control," Spirio said. "So we passed an ordinance last year that established an orderly process."

A fee of $100 ($50 for senior citizens) was imposed on applications for permits to have accessory apartments; the permits themselves cost $25 and must be renewed every two years; real estate taxes on the 1,200 houses in the program so far have been raised an average of $115.

Weston, Conn., another suburb of New York but one that has little else in common with Babylon, reports a similar success. Located in Fairfield County, it's an exclusive community with just under 9,000 residents, whose average income is $38,000 and whose average house is valued at $150,000. "It's the type of community that would be least likely to tolerate conversion," said First Selectman Susan Hutchinson.

But since the town passed a new set of zoning regulations in 1970, "we now have between 400 and 500 units among some 3,000 houses," Hutchinson said, "and you can't tell any difference from the outside."