How can i resize large images automatically in wordpress?

I was changing a wordpress theme for a client and the images seemed to be large for the new layout, while digging around i found a quick css solution for that to make it smaller and fit in the layout automatically instead of uploading the images again with the new size for all posts

this should tell wordpress that the maximum width of the image should be 98% of the container’s space.

hope it works for everyone who is looking for the same solution.