How to center text horizontally and vertically in a div

I had been trying to center the text in div element both vertically and horizontally. I had been searching for the solutions to this, but couldn't find anything which completely described my problem and the solution. Let me first explain what exactly I was trying to do: I was adding…