Same idea with the context of John 1:18.
John spoke figuratively a lot. "In the beginning was the Word." Jesus is not literally a "word" just like he is not literally "light." John speaks figuratively.
When John said "no man has seen God at any time" he then qualified that by saying Jesus is the one who explained what God is like in full heavenly glory. Jesus explained what God is like in His full heavenly glory. John learned from Jesus how to describe that heavenly glory: "God is love."