Your code is executed outside <article> DOM so it doesn’t have background styling as the rest of the content. I am not very familiar with this method but I believe that there must be a way to get content inside the actual content area. YOu might consider using some plugin that supports PHP code inside page.