Hey guys!

I know this might sound strange, but I am trying to use CSS to format a P section to be centered, but only if that P contains an embedded video.

Is there a CSS statement I can use to apply formatting to only those P's that contain OBJECT's (embedded videos)?

Basically, I'm trying to modify the parent based on the child...

Thanks a ton!

Recommended Answers

All 6 Replies

Basically, I'm trying to modify the parent based on the child...

As far as I am aware there is no way to do this with html/css alone.

Is the page being built dynamically using data base info or something? You can't just apply a class to that specific p tag?

Your best bet might be to use php or java, depending on how the content is put into the page, in order to apply a class to the p tag.

-David

Its a wordpress blog where the client is writing their own articles but they know nothing about HTML/CSS - so it has to automatically center the embedded video for them.

Unfortunately, I dont know enough about PHP to re-configure how wordpress builds the page when they publish an article.

Thanks for the suggestions.

Its a wordpress blog where the client is writing their own articles but they know nothing about HTML/CSS - so it has to automatically center the embedded video for them.

Unfortunately, I dont know enough about PHP to re-configure how wordpress builds the page when they publish an article.

Thanks for the suggestions.

You might try posting on the wp forum for a way to customize the loop output based on the content in a post, but it's going to be tough to find a solution that doesn't require you to modify the php.

Good luck.

Member Avatar for diafol

If the object is automatically placed in a p (or div), centring the object via the centre/center! align button on the WYSIWYG editor should do the trick. Objects themselves don't centre, so I understand the use of p. Some blogging platforms allow you to chose between p and div for new input. Both should work with the align buttons.

@ardav and @nizuya: guys, thanks a ton for the input. I actually figured out how to make it work and it was super-simple. I just needed to set the OBJECT to display:block and then the margin:auto worked. Don't know why I didn't think of that sooner.

Member Avatar for diafol

Nice one. Although - had issues with margin:auto in order browsers. Still had to centre-align the outer tag.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.