5. Let the three sides of $\triangle A B C$ be $B C=a, C A=b$, $A B=c$. If $\tan \frac{A}{2}=\frac{a}{b+c}, \tan \frac{B}{2}=\frac{b}{b+c}$, then $\triangle A B C$ is ( ).
(A) Isosceles triangle
(B) Right triangle
(C) Isosceles triangle or right triangle
(D) Isosceles right triangle
5. C.

Let $p=\frac{1}{2}(a+b+c)$, and the inradius of $\triangle ABC$ be $r$. Then
$$
\begin{array}{l}
\tan \frac{A}{2}=\frac{r}{p-a}=\frac{a}{b+c}, \\
\tan \frac{B}{2}=\frac{r}{p-b}=\frac{b}{b+c} .
\end{array}
$$
Dividing (1) by (2) gives
$$
\begin{array}{l}
\frac{p-b}{p-a}=\frac{a}{b+c} \cdot \frac{a+c}{b} \\
\Rightarrow \frac{2(p-b)}{2(p-a)}=\frac{a(a+c)}{b(b+c)} \\
\Rightarrow b(b+c)(c+a-b)=a(a+c)(b+c-a) \\
\Rightarrow b(b a-b^{2}+c^{2}+c a)=a(a b+b c-a^{2}+c^{2}) \\
\Rightarrow a b^{2}-b^{3}+b c^{2}+a b c=a^{2} b+a b c-a^{3}+a c^{2} \\
\Rightarrow a b^{2}-b^{3}+b c^{2}=a^{2} b-a^{3}+a c^{2} \\
\Rightarrow (a-b)\left(a^{2}+b^{2}-c^{2}\right)=0 \\
\Rightarrow a-b=0 \text { or } a^{2}+b^{2}-c^{2}=0 \\
\Rightarrow a=b \text { or } a^{2}+b^{2}=c^{2} \\
\Rightarrow \angle A=\angle B \text { or } \angle C=90^{\circ} .
\end{array}
$$

Thus, $\triangle ABC$ is an isosceles triangle or a right triangle.