WordPress.org

Forums

P tag surrounding my divs - No! Bad WP (7 posts)

  1. jeremyduffy
    Member
    Posted 7 years ago #

    I like the auto P behavior most of the time, but I don't want it to surround my div tags with paragraphs because I use divs for floating elements and other things. The extra spacing is really a bother since I can just control the spacing manually with styles when using divs.

    Any simple fix for this or do I need to hack wordpress.

  2. jeremyduffy
    Member
    Posted 7 years ago #

    Note I do not use the WYSIWYG editor

  3. jeremyduffy
    Member
    Posted 7 years ago #

    Also note that the div tag in question is the very first thing in the post.

  4. Joni
    Member
    Posted 7 years ago #

    There's a plugin that disables that (annoying) behavior:
    http://www.urbangiraffe.com/plugins/disable-wpautop

  5. jeremyduffy
    Member
    Posted 7 years ago #

    The problem is that I like the behavior generally because then I don't have to hand code <P> tags for every piece of text. I just wish that it would leave Divs alone. I'm thinking of hacking wpautop myself. It might be easier :(

  6. csleh
    Member
    Posted 7 years ago #

    Perhaps you could use a custom field for the div? You could also generate a class for the field using an additional key. Haven't tried it myself except with images. Seems like you could modify the code found here to check if there is a div before content, then the class would handle the layout.
    http://justintadlock.com/archives/2007/10/27/wordpress-custom-fields-adding-images-to-posts

    Let us know what you find that works.

  7. jeremyduffy
    Member
    Posted 7 years ago #

    So far the only thing that seems to be working is to set the top margin of all P tags to 5px. It requires some adjustment to the rest of my CSS file, but it at least gets rid of the extra space at the top of the page.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags