Early life and years as crown prince
Liu Ying's childhood is not completely clear. What is known is that he was not his father Liu Bang's oldest son—that would be Liu Fei, who would later be made the Prince of Qi. However, Liu Ying was considered to be the proper heir because his mother, the later Empress Lü, was Liu Bang's wife, while Liu Fei's mother was either a concubine or a mistress.
What is also known is that during Chu–Han Contention, when Liu Bang fought a five-year war with Xiang Yu for supremacy over the Chinese world, his mother, his sister, and he did not initially follow his father to the Principality of Han (modern Sichuan, Chongqing, and southern Shaanxi); rather, they stayed in his father's home territory, perhaps in his home town of Pei (沛縣, in modern Xuzhou, Jiangsu) deep in Xiang's Principality of Western Chu, presumably with his grandfather Liu Zhijia.
In 205 BC, Liu Bang appeared to be near total victory, having captured Xiang's capital of Pengcheng. How his family received this news was unclear, but a few months later, when Xiang responded and crushed Liu's forces, Liu fled and, in his flight, attempted to pass through his home town to take his family with him. He was able to find his children and carry them along with him, but his father and wife were captured by Xiang's forces and kept as hostages—and would not be returned to him until Liu and Xiang temporarily made peace in 203 BC. The then-very young Liu Ying must have then spent these days not knowing what the eventual fate of his grandfather and mother would be.
After Liu Bang's victory and self-declaration as the emperor (later known as Emperor Gao), thus establishing the Han Dynasty, in 202 BC, he made his wife empress and Liu Ying, as his proper heir, crown prince. Under the title of Ying Taizi ("Crown Prince Ying"), he was considered to be kind and tolerant, characteristics that Emperor Gao did not like. Rather, he favored his young son Liu Ruyi, whom he considered to be more like him and whose mother, Consort Qi, was his favorite concubine. With the support of the officials, however, Prince Ying's status as heir survived despite Consort Qi's machinations.
As crown prince, Prince Ying, along with his mother, would be the ones who would rule on important matters at the capital in his father's absence during various campaigns. When Ying Bu rebelled in 196 BC, Emperor Gao was ill and considered sending Prince Ying as the commander of the forces against Ying Bu rather than campaigning himself, but at the suggestion of Empress Lü (who averred that the generals, who were generally Emperor Gao's old friends, might not fully obey the young prince), went on the campaign himself. Prince Ying was instead put in charge of home territories around the capital Chang'an, assisted by Confucian scholar Shusun Tong (叔孫通) and strategist Zhang Liang (張良). He appeared to carry out the tasks competently but without distinction.
Prince Ying succeeded to the throne of Han when his father died in 195 BC from complications of an arrow wound suffered during the campaign against Ying Bu.