Highlighting text in html using different color background by span tagWe can mark any area of a text in different color background. This way we can highlight some portion of the text. We will be using span tag in html to give color background to the text. Note that we are not using bold tag here to highlight the font in bold letters.
With Div tagSpan tag is also used along with div tag for generating power full CSS effects. We will try how we can format a particular area of text by using span tag and style sheet.
Before that let us start with an simple example. Using span tag we can mark different areas in different colors. Here is the code for a simple span tag.
Welcome to plus2net html section. Use the forum to post any query / doubts on the tutorial
Here is the code
Span tag with CSSLet us use span tag along with CSS to define a format for text. We will keep the following code inside the head tags of our html page. This way we are creating one embedded style sheet which will affect the document only.
Now in our text inside the body of the page we can use this formatting where ever we want like this.
Span tag with background imageWe can place background image by using span tag like this.
Output is here
Span tag with mouse hover styleWe can create one span tag with title style to display any message once mouse is placed over it.
To check the example place your mouse here and wait.
This article is written by plus2net.com team.