
34 Cal.2d 112 (1949)
DELOS WAYNE SCHRADER et al., Respondents,
v.
JOHN NEVILLE et al., Appellants.
L. A. No. 20932. 
Supreme Court of California. In Bank.  
July 1, 1949.
 Monta W. Shirley for Appellants.
 Parker, Stanbury & Reese and John Henry Peckham for Respondents.
 EDMONDS, J.
 Delos W. Schrader and his wife sued to recover damages assertedly sustained as the result of the collision of two automobiles. The defendants, John Neville and his wife, filed a cross-complaint for damages claimed by them because of the same accident, and upon a trial neither party recovered against the other. The Nevilles then moved "to tax, disallow and annul the memorandum of costs filed by" the Schraders and the appeal is from an order allowing such costs.
 The position of the appellants is that, as the prevailing parties in the action, they are entitled to recover the costs of the litigation. The Schraders argue that, because the cross-complaint states an entirely separate cause of action, they must be considered as the prevailing parties, insofar as the issues in that regard are concerned, and the court correctly awarded costs to them.
 Section 1032 of the Code of Civil Procedure authorizes the recovery of costs in an action in the superior court "(a) To plaintiff upon a judgment in his favor ... [and] (b) To the defendant upon a judgment in his favor. ..." In effect, say the appellants, this means "costs shall be awarded to the prevailing party" in the action. However, according to the Nevilles, they defeated the cause of action sued upon by the Schraders and received, to use the words of the statute, "a judgment in their favor in an action for the recovery of damages." *114
 Unlike the statutes in many jurisdictions, our code section is not framed in the express language of the "prevailing party" but it allows the recovery of costs upon that basis by specifying as the condition for an award of them, "a judgment in his favor." The difficulty arises when a defendant files a pleading denominated by him as a "cross-complaint," for it is established that, under such circumstances and for certain purposes, "there are two simultaneous actions pending between the same parties wherein each is at the same time both a plaintiff and a defendant." (Pacific Finance Corp. v. Superior Court, 219 Cal. 179, 182 [25 P.2d 983, 90 A.L.R. 384]; see, also, Millar v. Millar, 51 Cal.App. 718, 721 [197 P. 811]; Luse v. Peters, 219 Cal. 625, 630 [28 P.2d 357].) In that situation it persuasively may be argued that a judgment for the cross-defendant entitles him to costs of the cross-action insofar, at least, as such cross action was necessarily denominated a "cross- complaint."
 [1] However, under our system of procedure, there is a very shadowy line of distinction between a cross-complaint and a counterclaim and a considerable area in which they overlap. If, therefore, the claim asserted by the defendant is within this area and it is pleaded as a counterclaim, no question concerning the allowance of costs will arise, because not even in the technical sense does the claim defensively pleaded come within the language of section 1032 of the Code of Civil Procedure. Accordingly, the respondents seek to have the right to costs turn on the name of the pleading chosen by the Nevilles and not by the substance of their claim. [2] But it is well established that as between a counterclaim and a cross-complaint the nature of the pleading will be determined from its allegations regardless of its designation. (Terry Trading Corp. v. Barsky, 210 Cal. 428 [292 P. 474]; Cornblith v. Valentine, 211 Cal. 243 [294 P. 1065]; Robertson v. Maroevich, 42 Cal.App.2d 610 [109 P.2d 708].)
 [3] The Nevilles' claim was one which could have been pleaded as either a counterclaim or a cross-complaint and this court may, in its discretion, treat it as either to the end that substantial justice may be done. [4] Moreover, section 439 of the Code of Civil Procedure provides: "If the defendant omits to set up a counterclaim upon a cause arising out of the transaction set forth in the complaint as the foundation of the plaintiff's claim, neither he nor his assignee can afterwards maintain an action against the plaintiff therefor." Under that provision, the claim by the Nevilles must have *115 been pleaded by them in the Schraders' action or it would have been barred, because it is established that all causes of action arising out of an automobile accident are part of one transaction" within the meaning of the code sections relating to cross-complaint and counterclaim. (Todhunter v. Smith, 219 Cal. 690 [28 P.2d 916]; Englemen v. Superior Court, 105 Cal.App. 754 [288 P. 723].) [5] It is only when the defendant's claim must necessarily be pleaded as a cross-complaint that "the failure to assert it does not bar a later action." (Sawyer v. Sterling Realty Co., 41 Cal.App.2d 715, 721 [107 P.2d 449].)"
 [6] By filing the complaint, the Schraders commenced litigation concerning the liabilities of the respective parties for the injuries sustained as a result of the accident. Although the Nevilles might not have sued to recover damages, when made defendants in the action, they were compelled to then assert any claim which they might have against the Schraders arising out of the collision. (Code Civ. Proc.,  439.) Having defeated the claim of the Schraders, as stated in Gerstein v. Smirl, 70 Cal.App.2d 238 [160 P.2d 585], the appellants are entitled to their costs for "a party who defeats an action by a counterclaim is as much entitled to his costs as is a party who defeats it by any other means. In an action such as the instant one for damages, the 'net result' of a judgment which awards nothing to plaintiff is favorable to the former. Although the defendant did not recover on her cross-complaint, she was the prevailing party in the court below because plaintiff was denied recovery against her." (See, also, Ballard Transfer & Storage Co. v. St. Paul City Ry. Co., 129 Minn. 494 [152 N.W. 868, 869]; Checketts v. Collings, 78 Utah 93 [1 P.2d 950, 75 A.L.R. 1393], note 75 A.L.R. 1400.) The holding in Borror v. Berry, 51 Cal.App.2d 552, 554 [125 P.2d 537], insofar as it concerns the question of costs, is inconsistent with the rule above stated and is disapproved.
 The order is reversed.
 Gibson, C.J., Shenk, J., Traynor, J., Carter, J., Schauer, J., and Spence, J., concurred.
