|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Is there a "neutral" HTML tag to hold CSS class or id specification ?
I have a paragraph --
<p>Now is the time for all good men...</p> Several phrases are highlighted with color -- <p>Now is the <font color="red">time</font> for all <font color="green">good</font> men ...</p> I want to use css instead of the font tag. I can use <i> or <b> tags with "css id or class" -- <p>Now is the <i id="myRed">time</i> for all <b id="myGreen">good</b> men ...</p> My question -- Is there a tag that does nothing? Just allows you to invoke some css id or class? What "neutral" tag can I use in place of the following question marks? <??? id="myRed"> I feel like I am missing the obvious way to do this ( without <font> ). Robert
__________________
Robert --- If it's hard, it's probably wrong. |
|
#2
|
||||
|
||||
|
Try something like this:
<span class="green">my text in green</span> |
|
#3
|
|||
|
|||
|
or:
<div id="myRed">text</div> |
|
#4
|
|||
|
|||
|
dunxster and pippo,
Thanks for the ideas. I tried the following on NN4.7 Now is the <span id="bfgRed">time</span> for all <div id="bfgGreen">good</div> men to ... <span... was ignored. <div... made the word "good" green, but isolated "good" on a separate line. Maybe it would work on IE? Perhaps the HTML authors didn't see a need for an "exit" or a "no operation" for css. Robert |
|
#5
|
|||
|
|||
|
<span> is an inline element, you can have an unlimited amount of them on the same line.
<div> is a block-level element, you can only have one on a line (unless you change its style to display:inline). Use <span>, NS4 has no problems with, perhaps it was something in your stylesheet which threw it, or perhaps it was the id attribute in the <span>? I know NS4 has no problems with <span class="bla"> ![]() |
|
#6
|
|||
|
|||
|
When using styles for fragment of text you use the SPAN-tag. If it's a complete block of text you want to manipulate, use the DIV-tag. This is very clear when you use the background-color property on those tags.
When using the SPAN-tags around one word, together with background-color, only that word will have the specified bg-color. When using the DIV-tag on that same word, the whole line will have that background-color. |
|
#7
|
|||
|
|||
|
Thank you all -- jakke, jkd, dunxster, pippo
You were right <span and <div do work as you said. It was my error. ![]() I had an invalid comment at the end of a css line as suggested by jkd ( thank you ). It negated the following css line.So bfgRed was not recognized. Yet bfgGreen was OK. #fInDataHor {background-color: 33cc66; color: black; } // invalid comment #bfgRed {color: ff0000;} #bfgGreen {color: 00ff00;} Robert |
|
#8
|
|||
|
|||
|
Hi Robert,
You can use <span>, for in-line formating (i.e. no caridge returns) or <div> for block formating. Neather of these tags have any formating other than layout, so all you'll need to do is set the color to red using css as other properties will be inherited from the <p> tag. Hope this helps. Pete. |
|
#9
|
|||
|
|||
|
This may be a bit of a dumb question but how do you do a proper comment within CSS? I thought it was //...
__________________
Never say never. |
|
#10
|
||||
|
||||
|
Comments in CSS are as follows:
/* some comment goes here */ /* this is another one */ |
|
#11
|
|||
|
|||
|
ah, I see now... thanks
![]() |
|
#12
|
|||
|
|||
|
/**************************************
you can always span this comment over different lines ;-) which is handy to subdivide a long Style Sheet ***************************************/ Last edited by jakke : July 30th, 2001 at 05:28 PM. |
![]() |
| Viewing: Dev Shed Forums > Web Design > CSS Help > Is there a "neutral" HTML tag to hold CSS class or id specification ? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|