homepage Welcome to WebmasterWorld Guest from 174.129.80.166
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Pubcon Platinum Sponsor
Home / Forums Index / Code, Content, and Presentation / CSS
Forum Library, Charter, Moderators: DrDoc

CSS Forum

    
only text background color in CSS
manuel




msg:4392080
 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




msg:4394747
 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.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved