This is an area of confusion that is not well explained to Mandarin learners. My website ukmandarin.org is here to solve these problems in a simple and unique manner.
Allow me to dispel your confusion in one bitesize article.
In this article, I will focus on 的 as a possessive article only.
The difference in a nutshell
的 is for possession of physical objects or conceptual ideas. 之 means possessing something as an innate quality or natural connection.
Examples of 的
My computer 我的电脑
The dog’s bone 狗的骨头
A teacher’s method 教师的方法
The functions of a device 机器的功能
Housing prices 房产的价格 (Normally expressed as 房价)
Examples of 之
Nature’s beauty 大自然之美
The art of cooking 料理之道
The vicissitudes of life 生命之风雨
Lands of music 音乐之乡
The fragrance of lavender 薰衣草之香
Cross over 通用
Did you see the key difference? If so, then you are fortunate to have learnt in a few seconds what took me years to truly figure out myself.
In spoken language, people use 的 far more. However, 之 has a much more profound literary and poetic feel to it, so people often use it as an embellishment to their language, especially in written literary prose.
的 and 之 can sometimes be used in the same situation, but you should stick to the rules above for now, as you could easily just end making a fool of yourself.