Jump to content

background color, or "highlighting"


Guest tenor1
 Share

Recommended Posts

Guest tenor1

I want to place background color behind certain words and phrases in the text of my website homepage. I want to make the text appear like I used a highlighter pen in either red or yellow to make words and phrases stand out on the page.I have gone through the HTML and XHTML tutorials. I cannot find any instructions on how to "highlight" lines of text, or sections of lines of text.Help will be greatly appreciated.

Link to comment
Share on other sites

You'll need to use CSS. Here is an example:HTML:This <span class="yellowbg">word</span> is highlighted.CSS:.yellowbg { background-color: yellow; }

Link to comment
Share on other sites

Or, if you only need one section of words highlited, use this:<p style="background-color: yellow">Hilighted Text</p>

Link to comment
Share on other sites

Fermat,That works if you use paragraphs for all the blocks of text on your page, but paragraphs aren't always the semantically correct tag to use. I would recommend the method vchris suggests. Spans are a generic inline container, which can also be a portion of a paragraph,and you avoid the necessity of dealing with the margins and paddings, etc of a paragraph. Furthermore, using a class will typically use less bandwidth for multiple occurrences of the "highlighted text" on a page.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...