John 8: 12-13.
Then spake Jesus again unto them, saying, I am the Light of the World: he that followeth Me shall not walk in darkness, but shall have the light of life.
The Pharisees therefore said unto Him, Thou bearest record of Thyself; Thy record is not true.
Keep in mind that the incident with the woman caught in adultery was an interruption to what Jesus was teaching the people in the Temple during the Feast of Tabernacles. After those who had brought her to Jesus quietly tip-toed away, Jesus turned to the people and picked up where He had left off.
An important feature of the Feast of Tabernacles was a lighting of the Temple that gave a brilliant light over the entire city of Jerusalem. That must have been a couple of massive chandeliers! This lighting ceremony was done to remind the people of the pillar of fire (light) that guided them through the wilderness for so many years.
So Jesus didn’t just switch topics when He introduced Himself as the Light of the World; the statement was a continuation of what He had already been saying. Just as He is the Water of Life and the Bread of Life, so He is also the Light of the World. Anyone who follows Him will have the Light of Life, and will not be lost in spiritual darkness ever again.
As you can imagine, His bold statements enraged the Pharisees who remained. They immediately accused Him of testifying of Himself, blowing His own horn; they said He was a liar. They said His testimony wasn’t true.
As always, He rose to the challenge.