homepage Welcome to WebmasterWorld Guest from 50.19.172.0
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderators: not2easy

CSS Forum

    
only text background color in CSS
manuel



 
Msg#: 4392078 posted 4:47 pm on Nov 29, 2011 (gmt 0)

Just wanted to post an update on an ancient thread (too old to reply):
[webmasterworld.com ]

The goal:
Add a background to text only (not to the 100% wide p tag)

The "usual" solution:
use <span> to wrap your text and give it a background color.

The issue with the "usual" solution:
wysiwyg editors use <p> tags to wrap text, not <span> tags (and there are some discussions going on the SEO aspect of using <p> tags...)

My solution:
.contentcontainer p {background:white;display:inline;clear:left;float:left;}

Greetings,
Manuel

 

alt131

WebmasterWorld Senior Member 5+ Year Member



 
Msg#: 4392078 posted 1:49 pm on Dec 6, 2011 (gmt 0)

Hi Manuel, and a warm (if delayed) welcome to WebmasterWorld :)

Thank you for posting a solution to a common problem, but as I'm sure you're aware, floated elements default to display:block which over-rides the explicitly set display:inline. This technique is usually needed for small amounts of text, not usually a whole <p>, so setting the para to float may impact on the layout of other elements inside .contentcontainer.

For me the real issue is if the WYSIWYG editors are incorrectly wrapping all text in <p> elements, rather then only using <p> for paragraphs ;)

But your reference to discussions about the SEO aspect of <p> is really interesting. Can you explain a bit more?

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / CSS
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved