Support » Requests and Feedback » DIV-Tags instead of P-Tags for Paragraphs

  • I don’t know if this was already discussed elsewhere, but i would like to see the use of DIV-tags for paragraphs instead of P-tags (i think it’s in “wpautop()”).
    the reason: P-blocks can’t contain other blocklevel-elements and i prefer to “package” pictures in paragraphs (IMG) inside DIV-blocks to give them “padding” with background-color, captions etc…
    if there is a need to differe DIV-paragraphs from other DIV-blocks, WordPress could output paragraph-DIVs with a special class (DIV class=’txt’ … /DIV).

Viewing 14 replies - 1 through 14 (of 14 total)
  • IMG are inline level, they can be contained inside P.

    you can put img inside paragraph blocks, and with CSS you can do all the formating you want.
    Making p’s into div’s is a bad idea overall if you want to keep your site valid.

    I use a class inside the img tag. It works and it validates. Nice and minimalist. Nothing fancy.

    Thread Starter dogfood

    (@dogfood)

    @beel: you cant’t put DIVs in wordpress post-paragraphs, as they are embedded in P-paragraphs and wouldn’t validate.
    @root: show me how to put a caption under a IMG by tacking a class on IMGs …
    i repeat my main point:
    why not putting wordpress-posts in DIV-paragraphs instead of P-paragraphs?
    disadvantage: lacking default-margin
    advantage: much more power for the blogger, by being able to put block-level-elements inside posted paragraphs.
    comparing disadvantage and advantage, i would say: DIV-paragraphs are the way to go. there is by W3C-definition no reason to prefer P over DIV for tagging paragraphs.
    so i ask for modifying wordpress to output posts with DIV-paragraphs be default or at least adding a switch/an option to change it to your favoured flavor of paragraphs.

    don’t know if this would work, cuz i havn’t tried (in wordpress), but if all you want is an image win a box with a caption, how about using a definition list?
    pretty good example here. http://www.maxdesign.com.au/presentation/definition/dl-image-gallery.htm

    dogfood: I realize one cannot put DIVs in Ps and have it validate – don’t think I said one could or should. What I said was, I “package” my images in DIVs all the time – setting captions, backgrounds, border shadows, etc., in my posts. For example, this page is perfectly compliant:
    http://www.billhayes.us/wordpress/archives/2004/05/19/
    .

    “why not putting wordpress-posts in DIV-paragraphs instead of P-paragraphs?”
    Why not? “Semantic elegance.” Ps define paragraphs, so paragraphs should be put in Ps. A list is a list, a paragraph is a paragraph, etc, etc.

    Why not? “Semantic elegance.” Ps define paragraphs, so paragraphs should be put in Ps. A list is a list, a paragraph is a paragraph, etc, etc.

    TheJason hit it right on the head. P tags mean something, and they should be used whenever that meaning applies. DIV tags don’t mean anything -that’s the point of DIV tags- and so they should be used only when a more suitable element (one with meaning) is not available.
    It’s sad. Back when people wrote by hand -or even with typewriters- they thought about what things meant when they wrote. Nowadays, all they care about is what it looks like, without realizing that you can get both meaning and looks at the same time. All you have to do is think about meaning first, and then deal with looks.
    Ahem. Either way, what dogfood wants to do could probably be provided via a quicktag; perhaps something mimicking the old FIG tag that was proposed for HTML some years ago? Something like the following:
    (figure src=”url-of-image“)caption-goes-here(/figure)
    Translate this in a quicktag to a DIV tag floated and padded appropriately. This would contain a block-style IMG tag with the src provided, and the caption above or below that. Another way to do this would be with a two-row table, one row containing the image and the other row containing the caption, but the semantics of this are dubious (though not completely invalid; a figure and its caption could be said to be a form of tabular data even though it doesn’t quite follow the typical HTML model of a table).

    Why not? “Semantic elegance.” Ps define paragraphs, so paragraphs should be put in Ps. A list is a list, a paragraph is a paragraph, etc, etc.

    Forgive me if I am wrong, but a wordpress “Post” is not necesarily a paragraph, so I am also of the opinion that enclosing posts in < DIV class=”post” > is more correct than P is it not?
    A post could contain a paragraph, at which time the poster can quite happily use P tags. But equally a post could contain an image, or a blockquote or an object even.
    I’ve got pretty much the same issue as @dogfood, whereby if I use a blockquote in a bare post, it invalidates the page as xhtml. I have to instead close the built-in < p > tag, then re-open it after the blockquote.

    While everyone is arguing about what WP should or should not do tcervo has long ago posted the solution, elegantly and economically explained, and moved on. People.

    Sorry, I didn’t mean to dredge up an argument. I’m honestly asking if there is a cleaner way to add xhtml-valid < blockquotes > to my posts. Does tcervo’s solution solve this? Should I resort to using a < span > for my blockquotes?

    No. Blockquotes are a different problem to images. To maintain validation do not put in a line break just use the bq inline and let Wp do the parsing. I know. I have just had a long session with the validator. Believe me.

    bgracewood: WP has no problem handling blockquotes. I’ll add a blockquote only post and you can see that it validates. What problems are you having that you would need for it to be “cleaner”?

    OK – accept my apologies! I managed to get it to work by putting a new line before the < blockquote > and after the < /blockquote >. I like that it does all the < p > tags correctly now. This feature is kinda hidden though isn’t it?
    Thanks guys – sorry for dragging this topic off-topic!

Viewing 14 replies - 1 through 14 (of 14 total)
  • The topic ‘DIV-Tags instead of P-Tags for Paragraphs’ is closed to new replies.