
128 Cal.App.3d 403 (1982)
180 Cal. Rptr. 347
RAMON MENDOZA et al., Plaintiffs and Appellants,
v.
COUNTY OF TULARE et al., Defendants and Respondents.
Docket No. 4905.
Court of Appeals of California, Fifth District.
January 5, 1982.
*407 COUNSEL
Randall C. Lyon, Gary S. de Malignon, James LaPorte, Richard Barron, Lois E. Strain, Terry Smerling, Fred Okrand, Mark Rosenbaum, Gary Williams, Margaret C. Crosby, Allan L. Schlosser and Amitai Schwartz for Plaintiffs and Appellants.
Calvin E. Baldwin, County Counsel, Clark F. Ide and Robert L. Felts, Deputy County Counsel, for Defendants and Respondents.
OPINION
BACA, J.[*]
This is a prisoners' class action challenging the conditions at Tulare County jail. The trial court dismissed the action after granting respondents' general demurrer without leave to amend.
The complaint was filed on November 1, 1978. Appellants allege, in 10 causes of action, various violations of the federal and state Constitutions, the federal Civil Rights Act (42 U.S.C. § 1983), and the California Penal and Health and Safety Codes. The pleadings sought: (1) certification of plaintiff inmates as a class; (2) submission and implementation of a plan whereby the alleged grievances could be resolved; (3) if such a plan was not feasible, declaratory and injunctive relief restraining defendant from maintaining the unlawful procedures *408 and jail conditions; and (4) that the court retain jurisdiction until those conditions were corrected to the court's satisfaction.
On January 17, 1979, respondents filed a general demurrer arguing that appellants did not have standing to sue and that an action did not lie against Tulare County officials; in a supplemental memorandum they asserted that no community of interest existed between members of appellants' class. Supplemental memoranda were filed by both sides up to February 20, 1979.
On March 19, 1979, the court granted respondents' demurrer, without leave to amend, on the following grounds: (1) community of interest did not exist among the members of the class; (2) because writs of habeas corpus would more quickly and efficiently remedy appellants' grievances, exercise of declaratory relief jurisdiction was not necessary or proper at the time under the circumstances. The court also took judicial notice of the fact that the four named plaintiff inmates had been convicted and sentenced and were, at the time of the ruling, incarcerated in state penal institutions.[1]
On May 9, 1979, the court entered a judgment dismissing appellants' action. This appeal ensued.

FACTS
Material facts alleged in the complaint are treated as true for the purpose of ruling on a demurrer. (Gruenberg v. Aetna Ins. Co. (1973) 9 Cal.3d 566, 572 [108 Cal. Rptr. 480, 510 P.2d 1032].) The following is a summary of facts alleged in appellants' complaint.

The Parties
The named plaintiffs below were Ramon Mendoza, Carl James, Simon Duarte, Henry Borbon, and John McAllister. At the time the complaint was filed, Mendoza, James, Duarte and Borbon were incarcerated in Tulare County jail. Mendoza and Duarte were convicted prisoners serving sentences; James and Borbon were being held for the duration of their respective trials. McAllister was a Tulare County resident and taxpayer.
*409 The inmate plaintiffs brought the action on behalf of all other persons incarcerated in Tulare County jail serving sentences or awaiting trial on pending charges. All members of the class, which numbered in excess of 250 persons, lived under similar conditions in the jail.
The defendants were the County of Tulare and, in their official capacities, the county chief executive officer, the sheriff, the undersheriff, the captain of the jail, and each member of the county board of supervisors.

Jail Conditions
Tulare County jail is a 5-story structure containing approximately 250 prisoners in various stages of criminal proceedings.[2] Prisoners are housed in both single and common cells. The cells are crowded, windowless, and cell lighting is controlled from outside the cell by jail officers. Heating and ventilation are poor, and cell toilets are not partitioned.
A licensed physician is not on the premises or otherwise immediately available. A nurse is on duty certain days of the week, but inmates often must wait as long as two weeks to see her. Doctor visits are reserved for those with obvious and serious medical problems, and the wait for these visits might likewise be two weeks. Unsanitary facilities and lack of routine diagnostic and preventative services encourage the spread of disease and inmates are not permitted to possess even lawfully prescribed medication. Dentists are not available for routine services.
The jail does not maintain special treatment or rehabilitative facilities for inmates suffering from drug addiction. As a result, these prisoners are forced to go through narcotics withdrawal, thus creating a danger to themselves and to others.
The jail maintains no law library for inmates' use. As a result, inmates awaiting trial and those wishing to file habeas corpus petitions are deprived of adequate legal preparation. The jail likewise has no general library for recreational reading. Inmates are further deprived of many publications, including "Inside Out," a periodical dedicated to explaining the rights and reporting the problems of local detention facility inmates.
*410 On days inmates must appear in court, they are awakened at 3:30 a.m. and are kept in a "holding tank" for as long as three hours without blankets or mattresses. They are then transferred to a similar holding tank at court.
The county does not provide educational, rehabilitative or vocational training programs. Recreation is limited to a maximum one-half hour per week on a "sun deck" that is insufficient to allow physical exercise. Inmates frequently go three weeks without sun deck time. Televisions are, however, placed in hallways every other night.
Visitation privileges are limited to one-half hour per week in a booth that does not allow contact. Inmates are frequently deprived of visits on the ground that the booth is "unavailable." Moreover, inmates are not permitted to receive incoming phone calls. They may make outgoing calls with permission, but permission is subject to a deputy's discretion and is rarely granted. Mail is picked up at the officers' convenience, sometimes as early as 1 to 3 a.m.
Jail inmates are not adequately segregated, so that those with known propensities for violence and/or homosexual assault are housed with the general population, and those convicted of serious crimes are housed with misdemeanants in common cells. Those awaiting trial are not separated from convicts.
Meals are often cold, and sanitation is minimal. For example, beverages are served by dipping inmates' cups into a large vessel. As a result, ashes, dirt and the like are introduced into the vat upon each serving. Inmates are restricted to three showers per week; they often receive fewer. Each inmate is issued one towel per week. Clothing is limited to one pair of overalls and three pair of underwear per week.
Jail regulations are not posted throughout the jail and are not otherwise made available to prisoners. Inmates are not advised that they have a right to a hearing before discipline is imposed.
Finally, inmates are not accessible to voter registration, though many are eligible to vote, and are frequently not permitted to participate in religious services.
*411 Although the complaint at times ascribed the jail conditions to actions of the defendants collectively, it did not otherwise allege individual responsibility on the part of any named defendant.

DISCUSSION

I.

(1) Release of Inmate Appellants Did Not Render Their Claims Moot.

In its order granting respondents' demurrer below, the trial court noted that the four named prisoner plaintiffs had been released or transferred from Tulare County jail. It did not expressly rule that this fact mooted the class action. Nonetheless, respondent urges that the prisoners' claims were then moot since they were no longer inmates of the jail.
With respect to the named plaintiffs who were pretrial detainees  i.e., plaintiffs James and Borbon  respondents' argument is without merit. As appellants note, the United States Supreme Court has rejected mootness claims in cases where pretrial detainees are released or transferred subsequent to the filing of their complaint. (See Bell v. Wolfish (1979) 441 U.S. 520, 526, fn. 5 [60 L.Ed.2d 447, 460, 99 S.Ct. 1861, 1867]; Gerstein v. Pugh (1975) 420 U.S. 103, 110, fn. 11 [43 L.Ed.2d 54, 63, 95 S.Ct. 854, 861].) The court reasoned that the temporary and relatively brief duration of pretrial detention renders the claims of such detainees "capable of repetition, yet evading review," thus fulfilling the requirement of United States Constitution, article III. (Wolfish, supra, 441 U.S. at p. 526, fn. 5 [60 L.Ed.2d at p. 460, 99 S.Ct. at p. 1867]; Gerstein, supra, 420 U.S. at p. 110, fn. 11 [43 L.Ed.2d at p. 63, 95 S.Ct. at p. 861].)
Respondents place undue emphasis on the fact that the plaintiffs in Bell v. Wolfish were detainees at the time the class was certified. (Bell v. Wolfish, supra, 441 U.S. at p. 526, fn. 5 [60 L.Ed.2d at p. 460, 99 S.Ct. at p. 1867].) The court therein did not see that fact as controlling. In fact, it noted other factors negating mootness: live controversy between petitioners therein and members of the class represented by the named respondents, and the temporary nature of confinement at New York's Metropolitan Correctional Center. In Gerstein the court noted that although the plaintiffs in that case were detainees at the time their *412 complaint was filed, the record was unclear as to whether they remained in custody at the time the class was certified. (Gerstein, supra, 420 U.S. at p. 110, fn. 11 [43 L.Ed.2d at p. 63, 95 S.Ct. at p. 861].) Although this fact would ordinarily moot their claim, the court found the case a "suitable exception," stating: "The length of pretrial custody cannot be ascertained at the outset, and it may be ended at any time by release on recognizance, dismissal of the charges, or a guilty plea, as well as by acquittal or conviction after trial. It is by no means certain that any given individual, named as plaintiff, would be in pretrial custody long enough for a district judge to certify the class. Moreover, in this case the constant existence of a class of persons suffering the deprivation is certain." (Ibid., italics added.) More recently, the court reiterated the Gerstein rationale, stating: "Some claims are so inherently transitory that the trial court will not have even enough time to rule on a motion for class certification before the proposed representative's individual interest expires." (United States Parole Comm'n. v. Geraghty (1980) 445 U.S. 388, 399 [63 L.Ed.2d 479, 492, 100 S.Ct. 1202, 1209].)
The pretrial detainee appellants in the case at bench were in a similar position, and there is no indication that the situation of pretrial detainees at Tulare County jail had changed, resulting thereby in a continuous class of persons subject to the deprivations alleged in the complaint. We hold that the claims of the named pretrial detainees below did not become moot because of their later release or transfer.
The question of mootness pertaining to named plaintiffs who had been sentenced to a county jail term, and hence were not merely pretrial detainees differs only in the length of their detention in the jail facility. Some sentenced inmates may be in custody longer than pretrial or trial detainees; however, in many instances the converse could be true, especially for those awaiting long and involved felony prosecutions.
Although the record does not reflect the average sentence served by inmates at Tulare County jail, misdemeanor county jail confinement rarely exceeds one year. (See Pen. Code, §§ 18, 19a.) This fact alone may establish that these inmates are so "inherently transitory" that it would be difficult to find a group of representative plaintiffs who would, as a matter of certainty, remain inmates long enough for a court to determine the propriety of the class suit.
*413 Furthermore, the California Supreme Court has made it clear that appellate courts may reach the merits of cases raising serious public policy issues despite the discontinued interest of the immediate litigants. (See, e.g., DeRonde v. Regents of University of California (1981) 28 Cal.3d 875, 879-880 [172 Cal. Rptr. 677, 625 P.2d 220]; United Farm Workers of America v. Superior Court (1976) 16 Cal.3d 499, 503-504 [128 Cal. Rptr. 209, 546 P.2d 713]; Johnson v. Hamilton (1975) 15 Cal.3d 461, 465 [125 Cal. Rptr. 129, 541 P.2d 881]; Green v. Superior Court (1974) 10 Cal.3d 616, 622, fn. 6 [111 Cal. Rptr. 704, 517 P.2d 1168].) In Johnson v. Hamilton, supra, 15 Cal.3d 461, the court recognized that mootness problems are often dispelled in a class action context, stating: "Furthermore, petitioner in his second cause of action purports to represent a class of persons who are similarly barred from candidacy by reason of the subject charter provisions. Although the underlying controversy may be moot as to petitioner, others similarly situated may be affected and the issues as to them may not be moot." (Johnson v. Hamilton, supra, 15 Cal.3d at p. 465.) It thus appears that mootness does not bar resolution of a class claim where public interest in a matter is strong and unnamed class members maintain a live controversy therein.
Conditions at any correctional facility are a public concern, not only as to convicted inmates but especially as to unconvicted defendants awaiting trial who are clothed with the presumption of innocence. In the case before us, a class of unnamed plaintiffs stands to be affected by resolution of appellants' claim one way or the other. To render the case moot is to reject those existing and continuing claims.
Appellants and respondents agree that litigation of this type is complex and time-consuming. There is thus always the prospect that named class plaintiffs will, for whatever reason, lose a present interest in the outcome of the case. It would be unduly harsh to dismiss the present action for mootness, considering that almost five months elapsed between the filing of the complaint and the ruling on the demurrer.
The fact that there is a continuing interest of an unnamed class herein and that those plaintiffs who were inmates awaiting trial have an interest that cannot be dismissed as moot renders such claims valid and nondemurrable, if well pled. Named plaintiffs in the present case have a fiduciary duty to continue the litigation on behalf of the class after their release or transfer from the jail. (See La Sala v. American Sav. & Loan Assn. (1971) 5 Cal.3d 864, 871 [97 Cal. Rptr. 849, 489 P.2d 1113].) *414 The case should not, ultimately, have been dismissed on the ground of mootness.

II.

(2) Prisoner Plaintiffs Had Standing to Sue.

Respondents assert that the named prisoner plaintiffs below did not allege any specific, significant injuries that the court could redress, thus depriving these plaintiffs of standing.[3] This argument is without merit.
A party must allege facts sufficient to establish status as a "real party in interest." (Friendly Village Community Assn., Inc. v. Silva & Hill Constr. Co. (1973) 31 Cal. App.3d 220, 224 [107 Cal. Rptr. 123, 69 A.L.R.3d 1142].) In state courts, this requirement is met if a party establishes a right to relief in court (see ibid.); federal courts require that a plaintiff allege "distinct and palpable injury" traceable to defendant's conduct. (See, e.g., Duke Power Co. v. Carolina Env. Study Group (1978) 438 U.S. 59, 72-78 [57 L.Ed.2d 595, 610-614, 98 S.Ct. 2620, 2630-2633].)
Appellants allege that several practices and conditions at the Tulare County jail violated constitutional and statutory provisions. They further allege that respondents were responsible for these conditions. Although the named plaintiffs did not allege what specific injuries they personally suffered, and admit on appeal that some of the violations alleged did not affect every member of the class, they did allege membership in a class of inmates that was collectively subject to substandard jail conditions, and therefore to respondents' actions. As such, they appear to have shown sufficient injury. It further appears that incarceration under the conditions listed and described in the complaint state a cause of action of unlawful confinement. Their allegations are deemed true for purposes of the demurrer below and for this appeal. Proof at trial will be an altogether different matter (see Trafficante v. Metropolitan Life Ins. (1972) 409 U.S. 205, 209-210 [34 L.Ed.2d 415, 419-420, 93 S.Ct. 364, 367]); the allegations of the complaint do demonstrate actual injury.
*415 The named inmate plaintiffs had standing to sue.

III.

(3) Plaintiff Taxpayer Had Standing to Sue.

As noted previously, Tulare County taxpayer John McAllister joined the prisoners' suit below. McAllister alleged that maintenance of the county jail's "oppressive and inhumane conditions" resulted in useless and wasteful expenditure of public funds, causing irreparable harm to him and to the general public. Respondents urge that the suit was not properly brought as a taxpayer's suit.
Code of Civil Procedure section 526a authorizes taxpayer actions "restraining and preventing any illegal expenditure of, waste of, or injury to, the estate, funds, or other property of a county ... against any officer thereof...." The primary purpose of the statute is "to enable a large body of the citizenry to challenge governmental action which would otherwise go unchallenged in the courts because of the standing requirement." (Van Atta v. Scott (1980) 27 Cal.3d 424, 447 [166 Cal. Rptr. 149, 613 P.2d 210], quoting Blair v. Pitchess (1971) 5 Cal.3d 258, 267-268 [96 Cal. Rptr. 42, 486 P.2d 1242, 45 A.L.R.3d 1206].) Nonetheless, the existence of directly affected individuals who might also have standing to sue does not preclude a taxpayer's suit. (Van Atta, supra, 27 Cal.3d at pp. 447-448.) Thus, in Van Atta, the California Supreme Court held that a taxpayer had standing to challenge state statutes relating to pretrial own-recognizance release of criminal defendants, despite the fact that there were pretrial detainees, who were directly affected and could have brought suit themselves. (Id. at pp. 447-448.) Under Van Atta, directly aggrieved parties and taxpayers have concurrent standing to bring suit to enjoin government action.[4]
We hold that appellant McAllister had standing to bring his taxpayer suit.


*416 IV.

(4a) There Was a Sufficiency of Interest.

In its order granting respondents' demurrer, the trial court stated that the community of interest necessary for a class action was lacking because each prisoner would be required to litigate factual and legal issues peculiar to his own case. The court cited Daar v. Yellow Cab Co. (1967) 67 Cal.2d 695, 707 [63 Cal. Rptr. 724, 433 P.2d 732], and Bartlett v. Hawaiian Village, Inc. (1978) 87 Cal. App.3d 435 [151 Cal. Rptr. 392].
(5) In order to sustain a class action, parties must allege facts sufficient to establish (1) an ascertainable class; and (2) "a well defined community of interest in the questions of law and fact involved affecting the parties to be represented [citations]." (Daar v. Yellow Cab Co., supra, 67 Cal.2d at p. 704.) (4b) Respondents in this case do not challenge appellants' assertion that the prisoner class below was ascertainable. Instead, respondents reiterate the lower court's concern on the community of interest issue.
(6) The most extensive elaboration of the community of interest requisite is found in City of San Jose v. Superior Court (1974) 12 Cal.3d 447, 460 [115 Cal. Rptr. 797, 529 P.2d 701, 76 A.L.R.3d 1223]: "In determining whether sufficient community of interest exists to justify the maintenance of a class action, we start from certain settled premises: Before the imposition of a judgment binding on absent parties can be justified, it must be shown that substantial benefits both to the litigants and to the court will result. [Citations.] The burden of such a showing falls on plaintiff ..., and the ultimate determination of whether the class action is appropriate turns on the existence and extent of common questions of law and fact. As noted above, each member must not be required to individually litigate numerous and substantial questions to determine his right to recover following the class judgment; and the issues which may be jointly tried, when compared with those requiring separate adjudication, must be sufficiently numerous and substantial to make the class action advantageous to the judicial process and to the litigants." The court also noted that the class action device "rests on considerations of necessity and convenience, adopted to prevent a failure of justice." (Id., at p. 458.)
*417 (4c) Respondents argue that each prisoner's right to relief in this case depends on "facts peculiar to his case," thus amounting to a mere aggregation of individual claims. In support, respondents note that the complaint contains several causes of action alleging many violations, and that the interests of the different classes of inmates may vary. For example, pretrial detainees may have interests different from sentenced prisoners, and inmates addicted to drugs have peculiar needs not shared by other prisoners.
While respondents' point is well taken with respect to certain allegations in the complaint, the complaint clearly contains many allegations applicable to all persons in custody in the Tulare County jail. The common allegations, and the statutory or constitutional violations assigned to each, are as follows: (1) the failure to maintain a licensed physician in the jail, in violation of Penal Code section 4023; (2) inadequate, superficial medical treatment at the jail, denying appellants due process of law, constituting cruel and unusual punishment, violating the federal Civil Rights Act, and constituting a public nuisance; (3) the failure to allow phone calls to attorneys and others, depriving inmates of effective assistance of counsel, freedom of communication, and due process; (4) the failure to provide access to an adequate law library, depriving inmates of the right to effective self-representation and due process; (5) collectively, the constraints and deprivations suffered by inmates constitute cruel and unusual punishment in violation of the federal and state constitutions and the federal Civil Rights Act.[5]
Allegations peculiar to pretrial detainees are: (1) that such inmates are not segregated from the sentenced prisoners, in violation of Penal Code sections 4001 and 4002; (2) the aggregate of poor conditions denies pretrial detainees due process and equal protection of the laws; and (3) jail procedures for court appearances, which leave detainees exhausted and unable to competently testify, and the requirement that prison clothing be worn at pretrial motions, deny various constitutional rights. Finally, the allegation applicable only to inmate drug addicts is that no medical assistance or therapeutic programs are provided, in violation of Health and Safety Code section 11222.
For several reasons, we hold that the present case was permissibly brought as a class action.
*418 The class of plaintiffs herein is readily ascertainable. It consists of all of those incarcerated in the Tulare County jail at the time the complaint was filed. Existence of a separate category consisting of pretrial detainees in that population does not nullify the class since the majority of the allegations raised in the complaint apply equally to pretrial detainees and to sentenced inmates. In any event, respondent does not appear to challenge ascertainability in this appeal.
Although the causes of action set forth in appellants' complaint reveal some questions of fact and law that are inapplicable to the class as a whole, common questions substantially outweigh those applicable only to separate categories of the class. In point as to the instant situation is what was said in City of San Jose v. Superior Court, supra, 12 Cal.3d 447, that one prerequisite to a proper class suit is that "the issues which may be jointly tried, when compared with those requiring separate adjudication, must be sufficiently numerous and substantial to make the class action advantageous to the judicial process and to the litigants." (Id., at p. 460, italics added; see also Hamwi v. Citinational-Buckeye Inv. Co. (1977) 72 Cal. App.3d 462, 471 [140 Cal. Rptr. 215].) In the class herein, numerous allegations regarding medical care, heating, ventilation, light, access to a law library, telephone calls, mail, and the like, establish common factual and legal questions in which each class member has a profound interest. These conditions affecting the class as a whole clearly outweigh the fewer contentions pertaining solely to pretrial detainees or to drug addicts.[6]
Each member of the class herein will not be required to litigate "numerous and substantial questions" (City of San Jose, supra, 12 Cal.3d at p. 460) in order to establish a right to the remedy sought. Appellants' claims could focus primarily on respondents' actions or omissions, and the similarly situated class members would not be required to prove individual facts. If the court ultimately finds statutory and/or constitutional violations, declaratory and injunctive relief will lie to redress violations common to the class even though some apply only to individuals. In this regard, it is noted that appellants did not seek money damages. The remedy sought is declaratory and injunctive relief. Individual damages to class members, consequently, is not a problem. Both *419 City of San Jose, supra, 12 Cal.3d 447, and Bartlett v. Hawaiian Village, Inc., supra, 87 Cal. App.3d 435 are therefore distinguishable.
Moreover, this case was dismissed after the trial court granted a general demurrer without leave to amend. (7) In a class action, a demurrer should be overruled if "there is a reasonable possibility plaintiffs can establish a prima facie community of interest ..." at a later stage of the proceeding. (Vasquez v. Superior Court (1971) 4 Cal.3d 800, 813 [94 Cal. Rptr. 796, 484 P.2d 964, 53 A.L.R.3d 513]; see also Beckstead v. Superior Court (1971) 21 Cal. App.3d 780, 782-784 [98 Cal. Rptr. 779].) Such a possibility existed in this case.
Finally, as appellants point out, although there is a paucity of prisoner class action cases in California appellate decisions, there are a great many federal cases involving prison conditions brought as class suits. (See, e.g. Bell v. Wolfish, supra, 441 U.S. at p. 523 [60 L.Ed.2d at p. 458, 99 S.Ct. at p. 1866]; Procunier v. Martinez (1974) 416 U.S. 396, 398 [40 L.Ed.2d 224, 231, 94 S.Ct. 1800, 1804]; Jones v. Diamond (5th Cir.1981) 636 F.2d 1364, 1367 (en banc); Rutherford v. Pitchess (C.D. Cal. 1978) 457 F. Supp. 104, 107.) This, of course, is not controlling, but it is indicative that the class action is an appropriate remedial device to redress prisoners' grievances.
(4d) We thus conclude that, to the extent the trial court below based its decision and ultimate dismissal on lack of community of interest among appellants, it abused its discretion.

V.

(8) Declaratory Relief Is an Appropriate Remedy.

The trial court below stated that declaratory relief is not "necessary or proper" if an alternative remedy exists, and indicated that habeas corpus petitions could more quickly and effectively remedy each prisoner's individual grievance. By way of example, the court noted that within a nine-day period, named plaintiff Henry Borbon was able to obtain a court order requiring additional towels in the jail's "sick tank." Respondent urges that the court's decision on this point was correct.
Code of Civil Procedure section 1061 places the decision whether to grant declaratory relief within the discretion of the trial court: "The court may refuse to exercise the power granted by this chapter in any case where its declaration or determination is not necessary or proper at the time under all the circumstances." The discretion afforded the trial *420 court is not, however, unlimited. Before declaratory relief is denied on this ground, "`"it must clearly appear that the asserted alternative remedies are available to the plaintiff and that they are speedy and adequate or as well suited to plaintiff's needs as declaratory relief."'" (Siciliano v. Fireman's Fund Ins. Co. (1976) 62 Cal. App.3d 745, 755 [133 Cal. Rptr. 376], quoting Maguire v. Hibernia S. & L. Soc. (1944) 23 Cal.2d 719, 732 [146 P.2d 673, 151 A.L.R. 1062].) Moreover, doubts must be resolved in favor of granting declaratory relief. (Siciliano, supra, 62 Cal. App.3d at p. 755.)
The writ of habeas corpus is, of course, an appropriate procedure to challenge the legality of confinement or to allege unlawful restraint on liberty "... under any pretense whatever...." (Pen. Code, § 1473, subd. (a).) A habeas corpus petition is likewise available to seek a declaration and enforcement of an inmate's rights. (In re Davis (1979) 25 Cal.3d 384, 387 [158 Cal. Rptr. 384, 599 P.2d 690].)
Moreover, a trial court may grant habeas corpus petitioners "prospective or class relief" to redress recurring deprivations of rights at correctional facilities. (In re Brindle (1979) 91 Cal. App.3d 660, 675-676 [154 Cal. Rptr. 563].) The writ is thus an effective and versatile means by which to remedy persistent violations of prisoners' rights, and has been so used. (See, e.g., In re Henderson (1972) 25 Cal. App.3d 68 [101 Cal. Rptr. 479].)
It was, however, an abuse of discretion to grant respondents' demurrer without leave to amend on this ground. The trial court should have granted appellants the opportunity either to plead more specifically the bases for declaratory relief or to refile their action as a petition for habeas corpus. The court, in fact, could have treated appellants' complaint as such a petition. (See Cerda v. Superior Court (1974) 42 Cal. App.3d 491, 492 [116 Cal. Rptr. 896].) The judgment therefore cannot be supported on this basis.

VI.

(9) Inclusion of County Executives and Members of the Board of Supervisors as Defendants.

Relying upon Brandt v. Board of Supervisors (1978) 84 Cal. App.3d 598 [147 Cal. Rptr. 468], respondents assert that Tulare County as an entity, the chief executive of that county, and members of the county's *421 board of supervisors are not responsible for county jail conditions and are hence improper defendants in a suit challenging such conditions.
In Brandt, a petition was filed alleging that the Madera County Board of Supervisors and the county sheriff had violated Administrative Code, title 15, sections 1020-1023, in that the number and training of correctional officers at the county jail were inadequate. The trial court issued a writ of mandate to the sheriff and board of supervisors, requiring compliance with the statute. The board appealed. This court reversed, noting initially that the board of supervisors' statutory duty with respect to county jails is limited to providing the sheriff with sufficient food, clothing, and bedding for prisoners (Pen. Code, § 4015) and to pay expenses incurred in the keeping of prisoners (Gov. Code, § 29602). (Brandt, supra, at pp. 601-602.) The court then reviewed the trial evidence supporting insufficient appropriations of funds for jail personnel, and found the evidence was less than substantial. (Id., at pp. 602-603.)
The Brandt case thus delineated the scope of liability of a county board of supervisors with respect to jail conditions. In the present case, appellants made no allegation that insufficient funds were appropriated, although such an allegation is to be inferred from their allegations of substandard conditions and insufficient prisoner clothing. The board of supervisors' duty under Penal Code section 4015 to provide sufficient funds is raised, albeit unclearly. In addition to this allegation, the complaint generally alleged that the County of Tulare as an entity was responsible for the welfare of prisoners in the county jail, that the board of supervisors was likewise responsible, and that the chief executive of the county was responsible for allocation of funds to the jail. This chain of responsibility does not comport with the statutory mandate summarized in Brandt. The complaint, however, might have been amended to allege insufficient allocation of funds by the board to the jail and to properly allege the duties and responsibilities of the executive officer and of the county.
It is clear that the sheriff is a proper party (Brandt, supra), that appellants seek performance of duties allegedly mandated by constitution and statute, and that they seek to challenge the amount of funds allocated for jail maintenance. The California Supreme Court has stated that it is an abuse of discretion to sustain a demurrer without leave to amend if there is a reasonable possibility that the defect, if any, can be cured by amendment. (La Sala v. American Savings & Loan Assn., supra, 5 Cal.3d 864, 876.) It appears that appellants can amend their *422 complaint to allege in more specific or accurate detail the respective responsibilities of the respondents.
To the extent that the trial court considered certain respondents to be improper parties, the court abused its discretion in granting a general demurrer without leave to amend.
For the foregoing reasons, it is concluded that the court abused its discretion in dismissing appellants' action after granting the demurrer without leave to amend. The grounds urged by the respondents in proceedings below simply did not warrant denial to the appellants of the proper opportunity to offer evidence supporting their allegations or to amend their pleadings.
The judgment of dismissal is reversed. The trial court is directed to allow appellants an opportunity to amend their pleadings consistent with the views herein expressed.
It is noted that reversal will not resolve the very difficult legal issues presented by appellants; it will, hopefully, allow a hearing and trial on the merits of these problems. Federal cases demonstrate that these constitutional issues are indeed difficult (see, e.g., Bell v. Wolfish, supra, 441 U.S. 520 [60 L.Ed.2d 447, 99 S.Ct. 1861]; Jones v. Diamond (5th Cir.1981) 636 F.2d 1364 (en banc); Miller v. Carson (5th Cir.1977) 563 F.2d 741; Rutherford v. Pitchess, supra, 457 F. Supp. 104), but they seem to agree on one point: the trial courts "must diligently ensure compliance with constitutional requirements and with statutes designed to improve prison conditions." (Wright v. Rushen (9th Cir.1981) 642 F.2d 1129, 1135.)
Zenovich, Acting P.J., and Woolpert (W.R.), J.,[*] concurred.
NOTES
[*]   Assigned by the Chairperson of the Judicial Council.
[1]  The dates of the commencement of the action, subsequent pleadings and final disposition are significant in view of the issues of speedy remedy and mootness.
[2]  The trial court took judicial notice of this fact; it is not found in appellants' complaint.
[3]  Although this point was raised by respondents below, the trial court did not comment on it in the order granting the demurrer. Respondents rightly point out, however, that the order granting the demurrer may be affirmed on any ground raised by the demurring party below. (Irwin v. City of Manhattan Beach (1966) 65 Cal.2d 13, 20 [51 Cal. Rptr. 881, 415 P.2d 769].)
[4]  DiSuvero v. County of Los Angeles (1977) 73 Cal. App.3d 718 [140 Cal. Rptr. 895], relied upon by respondents, was expressly disapproved in Van Atta v. Scott, supra, 27 Cal.3d at page 449.

A case following Van Atta denied taxpayer standing to a party who filed suit challenging jail conditions after a prior inmate suit had proceeded to judgment. (Cornblum v. Board of Supervisors (1980) 110 Cal. App.3d 976, 981-982 [168 Cal. Rptr. 294].)
[5]  This cause of action apparently encompassed various allegations such as inadequate heat, lighting and ventilation.
[6]  Although Code of Civil Procedure section 382 speaks only of a "question of common or general interest," Federal Rule of Civil Procedure 23 additionally states, inter alia, that whether "questions of law or fact common to the members of the class pre dominate over any questions affecting only individual members" is a factor supporting class certification. (Rule 23(b)(3).) This appears to be identical to the approach taken by the court in City of San Jose, supra. (See Occidental Land, Inc. v. Superior Court (1976) 18 Cal.3d 355, 360-361 [134 Cal. Rptr. 388, 556 P.2d 750].)
[*]   Assigned by the Chairperson of the Judicial Council.
