
21 Cal.3d 218 (1978)
577 P.2d 1031
145 Cal. Rptr. 691
INTERNATIONAL INDUSTRIES, INC., Plaintiff and Respondent,
v.
MAURICE OLEN, Defendant and Appellant.
Docket No. L.A. 30760.
Supreme Court of California.
May 8, 1978.
*220 COUNSEL
Myron W. Curzon for Defendant and Appellant.
Hill, Wynne, Troop & Meisinger, Louis M. Meisinger and Barbara A. Hindin for Plaintiff and Respondent.
OPINION
CLARK, J.
Proceeding to review order denying defendant costs and attorney's fees following plaintiff's voluntary dismissal without prejudice.
Plaintiff sublessor and defendant sublessee entered a written sublease providing for plaintiff's costs and attorney fees incurred in enforcing plaintiff's rights under the agreement. Plaintiff served amended notice to pay or quit in December 1975. In the same month, plaintiff filed complaints in superior court to recover rent and in municipal court for unlawful detainer. In the superior court action, plaintiff alleged damages of more than $5,000 for defendant's breach of the lease. The complaint also sought recovery of reasonable attorney fees.[1]
In January 1976, defendant returned to plaintiff the key to the demised premises. Plaintiff advised defendant acceptance of the key and efforts to relet were not to be interpreted as waiver of plaintiff's right to recover damages. (Civ. Code, § 1951.2, subd. (d).) Plaintiff subsequently relet the premises for a higher rental than that provided in the lease.
In February 1976, plaintiff agreed to defendant's request for extension of time to answer, plaintiff offering to settle for $700. Defendant rejected the offer and answered in the superior court alleging that plaintiff had waived payment of rent until 1 March 1976, that plaintiff had refused *221 defendant's tender of rent, that defendant had never occupied the premises, and that plaintiff had relet at increased rental. Defendant also filed and served written interrogatories.
On 26 April 1976, plaintiff filed request for voluntary dismissal without prejudice in the superior court action. (Code Civ. Proc., § 581, subd. 1.) Defendant was not immediately notified of plaintiff's request. On 29 April 1976, the superior court granted defendant's motion to compel answers to interrogatories and imposed a sanction of $200 on plaintiff. Plaintiff requested dismissal of the municipal court proceeding on 30 April 1976. Defendant received notice of dismissal as to each action on 6 May 1976. Plaintiff then paid defendant the $200 sanction, informing him that in light of the dismissals plaintiff would not answer the interrogatories.
After being notified of the dismissals, defendant moved for entry of judgment in the superior court. He also filed a memorandum of costs alleging $35 filing fee and $1,285 attorney fees. Plaintiff moved to tax costs and to strike defendant's memorandum on the ground defendant was not the prevailing party. The superior court granted plaintiff's motions and denied defendant's motion for entry of judgment.
We conclude defendant is entitled to recover his filing fee as costs, but not his attorney fees.

FILING FEE
(1) Code of Civil Procedure section 1032 provides in relevant part: "In the superior court, except as otherwise expressly provided costs are allowed of course: ... [¶] (b) To the defendant upon a judgment in his favor in special proceedings and in actions mentioned in subdivision (a) of this section, or as to whom the action is dismissed. ..." (Italics added.)
Filing fees are recoverable as costs. (4 Witkin, Cal. Procedure (2d ed. 1971) Judgment, § 101, p. 3257; Cal. Civil Procedure During Trial (Cont.Ed.Bar 1960) § 23.26, p. 619.) The above emphasized portion of section 1032 entitles defendant to filing fees as a matter of right.

ATTORNEY FEES
(2) Unless authorized by statute or agreement, attorney fees ordinarily are not recoverable as costs. (Code Civ. Proc., § 1021; D'Amico v. *222 Board of Medical Examiners (1974) 11 Cal.3d 1, 24-27 [112 Cal. Rptr. 786, 520 P.2d 10]; Freeman v. Goldberg (1961) 55 Cal.2d 622, 625 [12 Cal. Rptr. 668, 361 P.2d 244]; Young v. Redman (1976) 55 Cal. App.3d 827, 834-835 [128 Cal. Rptr. 86].)
(3) Defendant contends he is entitled to attorney fees by virtue of Civil Code section 1717. Section 1717 provides: "In any action on a contract, where such contract specifically provides that attorney's fees and costs, which are incurred to enforce the provisions of such contract, shall be awarded to one of the parties, the prevailing party, whether he is the party specified in the contract or not, shall be entitled to reasonable attorney's fees in addition to costs and necessary disbursements. [¶] Attorney's fees provided for by this section shall not be subject to waiver by the parties to any contract which is entered into after the effective date of this section. Any provision in any such contract which provides for a waiver of attorney's fees is void. [¶] As used in this section `prevailing party' means the party in whose favor final judgment is rendered." (Italics added.) Unlike section 1032, section 1717 contains no provision specifically providing for recovery on voluntary dismissal.
Associated Convalescent Enterprises v. Carl Marks & Co., Inc. (1973) 33 Cal. App.3d 116 [108 Cal. Rptr. 782], appears identical to the present case. In Associated  as here  the plaintiff procured a voluntary dismissal without prejudice pursuant to Code of Civil Procedure section 581, subdivision 1; the defendant  as here  contended it was entitled to attorney fees by virtue of section 1717. The court held the defendant was not entitled to attorney fees because no final judgment had been rendered in its favor. (Id., at pp. 120-121.) Associated reasoned the entry of judgment following voluntary dismissal is nonjudicial because performed by the clerk, and not final because such judgment does not determine the rights of the parties. (Id.) Finally, the court noted the rendition of a judgment is a judicial act, not a ministerial act like the entry of the voluntary dismissal. (Id., at p. 121.)
Gray v. Kay (1975) 47 Cal. App.3d 562 [120 Cal. Rptr. 915], is also identical to the present case. Gray followed Associated in holding that a voluntary judgment of dismissal does not involve rendition of a final judgment. (Id., at p. 565.) Similarly, in Samuels v. Sabih (1976) 62 Cal. App.3d 335 [133 Cal. Rptr. 74], the court held a dismissal procured by the defendant for want of prosecution (Code Civ. Proc., § 583, subd. (b)), is not an adjudication on the merits, and is not a final judgment within the meaning of section 1717. (Id., at pp. 339-340.)
*223 Section 1717 is obviously intended to create a reciprocal right to attorney fees when the contract provides the right to one party but not to the other. (System Inv. Corp. v. Union Bank (1971) 21 Cal. App.3d 137, 163 [98 Cal. Rptr. 735]; Review of Selected 1968 Code Legislation (Cont.Ed.Bar) pp. 35-36.) To implement legislative intent and determine which party is entitled to attorney fees, it is necessary first to consider the rules applicable to contractual claims for attorney fees.
Prior to enactment of section 1717, a contractual provision providing for attorney fees in favor of defendant was not deemed to permit, on procedural grounds, recovery when the plaintiff voluntarily dismissed prior to trial. In Genis v. Krasne (1956) 47 Cal.2d 241, 246 [302 P.2d 289], this court held that "where attorneys' fees are allowable solely by virtue of contract they cannot be recovered by merely including them in the memorandum of costs." (Italics in orig.) We specifically rejected the contrary rule of Wagner v. Shapona (1954) 123 Cal. App.2d 451, 454, 463 [267 P.2d 378]. (47 Cal.2d, at p. 246, fn. 2.) Since fees could not be taxed as costs, they could not be recovered after dismissal. Fees could not be recovered by the defendant during the proceedings prior to dismissal  there would be no opportunity to secure an award because the clerk was not authorized to delay entry of dismissal for determination of the award. Accordingly, prior to adoption of section 1717 recovery of fees by the defendant under a contractual provision was effectively barred when the plaintiff voluntarily dismissed prior to trial.
While the procedural bar to recovery of attorney fees in pretrial voluntary dismissal cases may have been removed (T.E.D. Bearing Co. v. Walter E. Heller & Co. (1974) 38 Cal. App.3d 59, 63 et seq. [112 Cal. Rptr. 910]), we are satisfied that sound public policy and recognized equitable considerations require that we adhere to the prior practice of refusing to permit recovery of attorney fees based on contract when the plaintiff voluntarily dismisses prior to trial.
In Ecco-Phoenix Electric Corp. v. Howard J. White, Inc. (1969) 1 Cal.3d 266, 272 [81 Cal. Rptr. 849, 461 P.2d 33], this court rejected literal and inflexible interpretation of attorney fee clauses, pointing out that literal construction of the clause before the court would permit  contrary to sound public policy  the promisee to recover even if he was responsible for the litigation, encouraging and in fact indemnifying vexatious and frivolous litigation. Although the contract provision in that case provided for defendant's recovery of fees for any litigation, this court held that fees could be recovered only to the extent necessary to protect the defendant's *224 rights and that where the plaintiff is partially successful, the plaintiff's liability is limited to fees for the part of the defense which was successful. Other cases have likewise recognized that the contractual provisions for attorney fees will not be inflexibly enforced and that the form of the judgment is not necessarily controlling, but must give way to equitable considerations. (National Computer Rental, Ltd. v. Bergen Brunswig Corp. (1976) 59 Cal. App.3d 58, 63 [130 Cal. Rptr. 360]; Babcock v. Omansky (1973) 31 Cal. App.3d 625, 633-634 [107 Cal. Rptr. 512]; Levy v. Ross (1969) 269 Cal. App.2d 231, 238 [74 Cal. Rptr. 622].) Nevertheless, some older decisions have taken a mechanical approach to attorney fees clauses.
Enactment of section 1717 commands that equitable considerations must rise over formal ones. Building a reciprocal right to attorney fees into contracts, and prohibiting its waiver, the section reflects legislative intent that equitable considerations must prevail over both the bargaining power of the parties and the technical rules of contractual construction.
Because award of contractual attorney fees is governed by equitable principles, we must reject any rule that permits a defendant to automatically recover fees when the plaintiff has voluntarily dismissed before trial. Although a plaintiff may voluntarily dismiss before trial because he learns that his action is without merit, obviously other reasons may exist causing him to terminate the action. For example, the defendant may grant plaintiff  short of trial  all or substantially all relief sought, or the plaintiff may learn the defendant is insolvent, rendering any judgment hollow. Such defendants may not recover attorney fees within the equitable principles of Ecco-Phoenix Electric Corp. Moreover, permitting recovery of attorney fees by defendant in all cases of voluntary dismissal before trial would encourage plaintiffs to maintain pointless litigation in moot cases or against insolvent defendants to avoid liability for those fees.
It has been suggested that in pretrial dismissal cases the court should determine whether, and to what extent, the complaint is meritorious and award attorney fees accordingly. However, to arrive at that determination would require the court to try the entire case. The purpose of litigation is to resolve participants' disputes, not compensate participating attorneys. Our courts are sufficiently burdened without combat kept alive solely for attorney fees.
*225 In pretrial dismissal cases, we are faced with a Hobson's choice of either (1) adopting an automatic right to attorney fees, thereby encouraging the maintenance of pointless litigation and violating the equitable principles which should govern attorney fee clauses, (2) providing for application of equitable considerations, requiring use of scarce judicial resources for trial of the merits of dismissed actions, or (3) continuing the former rule, denying attorney fees in spite of agreement. We are satisfied that concern for the efficient and equitable administration of justice requires that the parties in pretrial dismissal cases be left to bear their own attorney fees, whether claim is asserted on the basis of the contract or section 1717's reciprocal right.
The portion of the order denying defendant filing fees is reversed. The order otherwise is affirmed.
Plaintiff to recover costs on this appeal.
Bird, C.J., Richardson, J., and Manuel, J., concurred.
MOSK, J.
I dissent.
It has long been the rule that taxing costs and settling a cost bill are judicial functions, the result of which is a judgment for costs. (See Hopkins v. Superior Court (1902) 136 Cal. 552, 554 [69 P. 299].) The result may not be a determination on the merits of the underlying claim, but it is in all respects a final judgment.
Thus if, as the majority appear to agree, the defendant is entitled to his costs upon plaintiff's filing a voluntary dismissal, the defendant thereby satisfies the only requirement of Civil Code section 1717 for becoming a "prevailing party": he is "the party in whose favor final judgment is rendered."
When attorney's fees are recoverable pursuant to statutory authorization, they are deemed an element of costs. For example, Code of Civil Procedure section 874.010, relating to actions for partition of property, provides for recovery of the "costs of partition" which include "Reasonable attorney's fees"; section 836, relating to libel actions, provides a prevailing defendant shall recover $100 "to cover counsel fees in addition to the other costs"; and in eminent domain proceedings recoverable "litigation expenses," i.e., costs, include reasonable attorney's fees (Code *226 Civ. Proc., § 1235.140), and these, significantly, are to be awarded to a defendant whenever the "proceeding is wholly or partly dismissed for any reason" (Code Civ. Proc., § 1268.610).
Many authorities also refer to attorney's fees as an element of costs. (See e.g., System Inv. Corp. v. Union Bank (1971) 21 Cal. App.3d 137, 162 [98 Cal. Rptr. 735].) In Woodward v. Bruner (1951) 104 Cal. App.2d 83, 85 [230 P.2d 861], the court declared that the "rule of the common law that counsel fees were to be classed as costs and not damages is a part and parcel of our law," unless, of course, a statute or contract provides otherwise.
In view of the consistent references to statutory and contractual attorney's fees as an element of costs, we should construe section 1717 as providing for recovery of such attorney's fees whenever other costs are properly recoverable. Code of Civil Procedure section 1032 awards to a defendant "as to whom the action is dismissed" his costs, not merely part of his costs. Yet reduction to only a small fraction of actual costs results from the majority's strained interpretation permitting recovery of the filing fee but not attorney's fees pursuant to contract.
A voluntary dismissal terminates litigation with finality comparable to a formal judgment based on sustaining a demurrer, or on findings or a verdict on the facts. That there has been no determination of the merits and that a new lawsuit on the same subject may be filed have no bearing on the pragmatic result: termination of the pending litigation. No persuasive reason appears to insulate a plaintiff from his obligation to pay costs, including attorney's fees, merely because he elects to terminate litigation by means of dismissal rather than by pursuit to a conclusion on the merits.
I would reverse the order of the trial court.
Tobriner, J., concurred.
JEFFERSON, J.[*]
I dissent.
I agree with Justice Mosk's disagreement with the majority, but I place my disagreement on broader grounds.
*227 The majority relies in part upon the three cases of Associated Convalescent Enterprises v. Carl Marks & Co., Inc. (1973) 33 Cal. App.3d 116 [108 Cal. Rptr. 782]; Gray v. Kay (1975) 47 Cal. App.3d 562 [120 Cal. Rptr. 915]; and Samuels v. Sabih (1976) 62 Cal. App.3d 335 [133 Cal. Rptr. 74]. The majority apparently approves of the reasoning set forth in these three cases that a defendant is not entitled to attorney's fees under Civil Code section 1717 because a voluntary dismissal by plaintiff does not constitute a final judgment within the meaning of section 1717 which defines the prevailing party to be a party in whose favor a final judgment is rendered. In my view the reasoning advanced in these three cases is not persuasive. Hence, this court should disapprove of the results reached in these cases.
The majority presents no convincing reasons why a voluntary dismissal of an action by plaintiff should not be considered a final judgment for the purposes of making the defendant a prevailing party under section 1717. The fact that a plaintiff, who voluntarily dismisses his action without prejudice, may refile the action, does not preclude a holding that such dismissal is a final determination of that proceeding and is thus a final judgment. It is to be noted that Civil Code section 1717 does not require that a final judgment must be a judgment on the merits in order for a party to be a prevailing party.
The Legislature did not intend by use of the phrase "final judgment" in Civil Code section 1717 that a termination of a lawsuit should be considered a final judgment only if such termination was on the merits. In chapter 1 (Judgment in General) of title 8 of the Code of Civil Procedure, section 582 follows sections 577 through 581 which deal with an assortment of various types of judgments which are not judgments on the merits. Section 582 follows with its provisions that "[i]n all other cases judgment shall be rendered on the merits." Had the Legislature in section 1717 of the Civil Code intended that, for the purposes of obtaining attorney's fees, a prevailing party shall be limited to a party who has obtained a final judgment on the merits in his favor, language similar to that set forth in Code of Civil Procedure section 582 would have been used.
Since a plaintiff's voluntary dismissal of an action "finally disposes of the particular action and prevents further proceedings as effectually as would any formal judgment based on ruling on demurrer, or on findings or verdict on the facts" (Southern Pac. R.R. Co. v. Willett (1932) 216 Cal. 387, 390 [14 P.2d 526]), it should be deemed a final judgment in *228 defendant's favor  thus carrying out the legislative intent of Civil Code section 1717 to permit defendant's recovery of attorney's fees as the prevailing party.
The majority reaches its result primarily on what it deems "sound public policy and recognized equitable considerations." The majority places heavy reliance upon Ecco-Phoenix Electric Corp. v. Howard J. White, Inc. (1969) 1 Cal.3d 266 [81 Cal. Rptr. 849, 461 P.2d 33]. The majority points out that the Ecco-Phoenix Electric Corp. court rejected a literal and inflexible interpretation of an attorney's fee clause in the parties' written contract involved in that case, and applied equitable principles, and that these principles support the majority's result in the case at bench. But I see nothing in the Ecco-Phoenix Electric Corp. case which supports the majority's view that an application of "sound public policy" and "equitable considerations" to the case before us requires the result that a defendant should not be entitled to attorney's fees when plaintiff voluntarily dismisses his action.
In Ecco-Phoenix Electric Corp., a printed form contract between a subcontractor and contractor, drawn by the subcontractor, contained a clause which provided: "`Should litigation be necessary to enforce any term or provision of this agreement, then all litigation and court costs and reasonable attorney's fees shall be borne wholly by the Sub-Contractor.'" (See Ecco-Phoenix Electric Corp., supra, 1 Cal.3d 266, 272.) (Latter italics added.) The court found this clause to be ambiguous, stating: "We find the clause less than certain on its face, leaving unanswered such questions as `litigation' by whom, and made `necessary' by whom." (Id., at p. 272.) The court concluded that a "reasonable interpretation" of the attorney's fees clause required the subcontractor to be "liable for costs and attorney's fees only if it, the subcontractor, has made the litigation `necessary.'" (Id., at p. 272.)
All that the Ecco-Phoenix Electric Corp. court did was to reject a literal interpretation of the attorney's fee clause and apply generally recognized standards of contractual interpretation. Thus, the court stated: "As this printed form contract was prepared by defendant, and in light of the oppressive nature of a literal interpretation of the clause, we resolve any uncertainties in favor of a fair and reasonable interpretation and against the inflexible construction adopted by the trial court. [Citations.]" (Ecco-Phoenix Electric Corp., supra, 1 Cal.3d 266, 272.)
*229 The case at bench does not begin to present a problem of a literal construction of Civil Code section 1717 of an oppressive nature and which would produce an inequitable result. The language used by the Legislature in section 1717 is not remotely similar to the one-sided language of the printed form contract which Ecco-Phoenix Electric Corp. found to be oppressive if interpreted literally. The majority takes the view that to interpret section 1717 to permit a defendant to recover attorney's fees when a plaintiff voluntarily dismisses an action before trial would constitute a mechanical application of the section. But the majority's result produces a mechanical application of section 1717  a type of application which it professes to abhor. If an automatic award of fees to defendant in such a case constitutes a mechanical application of the section, so does the majority's result of automatically denying fees upon a plaintiff's voluntary dismissal of the action. An interpretation of section 1717 cannot rest logically or reasonably upon the assumption that one interpretation represents a mechanical application of the statute while the reverse interpretation is grounded in sound public policy and equitable considerations.
The majority seems to think that permitting a defendant to recover attorney's fees in cases of a voluntary dismissal by a plaintiff would encourage plaintiffs to maintain pointless litigation. In my view the recovery of attorney's fees by a defendant upon a voluntary dismissal of the action by plaintiff would be in the interest of sound public policy and in accord with equitable principles, since it would tend to discourage the filing of nonmeritorious actions by a party to a contract containing an attorney's fee clause. With knowledge that a voluntary dismissal will result in fees to the defendant, one party to the contract is not likely to start litigation based on the contract unless such party feels he has a reasonable opportunity of prevailing.
I find no magic in language used by the majority  sound public policy and equitable considerations. Both of these concepts, like beauty, have different meanings, dependent upon the eyes and ideas of the beholder. I consider that the majority's view of adopting an interpretation of Civil Code section 1717 that denies to defendant a right to attorney's fees when there is a voluntary dismissal by plaintiff will encourage the filing of fruitless and nonmeritorious litigation and does violence to the same sound public policy and equitable principles which the majority espouses on the basis of Ecco-Phoenix Electric Corp. The majority stresses the fact that, although a plaintiff may voluntarily dismiss his action before trial because it lacks merit, there are other reasons also which may cause a *230 plaintiff to terminate the action. But a recognition that there are various reasons which motivate different plaintiffs to voluntarily dismiss actions before trial offers no convincing argument that sound public policy or equity favors the plaintiff to justify denying to defendant an award of attorney's fees in this situation.
I would reverse the order of the trial court.
Tobriner, J., concurred.
NOTES
[1]  We are concerned here with only costs and attorney fees in the superior court action, the appeal having been taken from an order entered in that action.
[*]   Assigned by the Chairperson of the Judicial Council.
