NbC, HfC, TaC, and their solid solution ceramics have been identified as the best materials for ultrahigh-temperature ceramics. However, their structural stability and elastic properties are mostly unclear. Thus, we investigated structure and elastic properties of (Nb1-xTax)C and (Nb1-xHfx)C solid solutions via ab initio calculations. Our calculated results show that the stability of (Nb1-xTax)C and (Nb1-xHfx)C increases with the increase of Hf and Ta content, and (Nb1-xHfx)C is more stable than (Nb1-xTax)C at the same content of Hf and Ta. The lattice constants decrease with increasing of Hf and Ta content. (Nb1-xTax)C and (Nb1-xHfx)C carbides are mechanically stable and brittle. Bulk modulus of (Nb1-xTax)C increases with increasing Ta content. In contrast, bulk modulus of (Nb1-xHfx)C decreases with increasing Hf content. Hardness of solid solutions shows the highest values at the (Nb0.25Ta0.75)C and (Nb0.75Hf0.25)C. In particular, (Nb0.75Hf0.25)C shows the highest hardness for the current system. The results indicate that the overall mechanical properties of (Nb1-xHfx)C solid solutions are superior to those of (Nb1-xTax)C solid solutions. Therefore, controlling the Hf and Ta element and content of the (Nb1-xTax)C and (Nb1-xHfx)C Solid solution is crucial for optimizing the material properties.