Grow your CSS skills. Land your dream job.

WordPress Newbie Question: Best Practice for HTML in Posts

  • # June 26, 2013 at 11:00 am

    I’m still rather new to WordPress but wanted to ask a simple question that I can’t find on Google. When you’re building a post, how much HTML do you throw into a post? Do you give it structural divs around certain areas or do you stick with paragraphs? Do you give classes to those paragraphs in order to apply a certain style on them?

    How much is too much and what is the best practice? There are times when I feel I’m building out a mini web page within the site itself. Is that the ‘correct’ or ‘right’ way of doing it? Please share. Thanks!

    # June 26, 2013 at 6:23 pm

    Personally, I give as much leeway for styling as necessary. Wrapping each content part in html makes it easier to style. the_content outputs to p tags, so I usually don’t wrap it in additional p tags.

    Hope that helps!

    # June 26, 2013 at 9:31 pm

    Anything that is complex, if you break it down and work in small pieces, it becomes manageable. So yes you should be working on smaller pieces, essentially building up a puzzle.

    As for wrapping elements. Wrap them however you see fit. Divs are used to logically group elements, and they don’t represent anything really, they just help us group things. IMO classes should be applied to divs, and not paragraphs, unless you are trying to do something stylistically specific to it or if you are introducing some sort of JavaScript interaction.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.

*May or may not contain any actual "CSS" or "Tricks".