Forum Moderators: not2easy

Message Too Old, No Replies

Styling an individual element.

         

terrybarnes

12:14 pm on Oct 28, 2008 (gmt 0)

10+ Year Member



No, I know this must be really easy but my mind has gone blank today - it's cold outside and my brain has frozen!

I have a couple of elements on the page that use the same style of "background-position: -52px 0;" in the css but one of those I need to change the position but don't want to change it on the css - instead I'd like to add it just to the html. How do I do that?

I currently have:

<a id="button1a" href="index.html"><span class="alt">Test</span></a>
<a id="button2a" href="about.html"><span class="alt">Test 2</span></a>

but would like to change the background position on button2a to "background-position: -52px 32;"

Is there a way I can style the individual element in the HTML code? I'm sure I just need to add a style tag somewhere and then insert the background-position tag but I don't know where!

swa66

12:31 pm on Oct 28, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well the where to add it depends on what element the background is put in the CSS. Let's uppose it's on the <a>:


<a id="button2a" style="background-position: -52px 32">...

should do the trick.

terrybarnes

3:22 pm on Oct 28, 2008 (gmt 0)

10+ Year Member



Perfect, that works a treat - thanks for your help, very much appreciated.

g1smd

7:50 pm on Oct 28, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If this is for one button on one page, inline styling is OK.

If this is going on any more than one page, get it into the stylesheet.

terrybarnes

10:13 pm on Oct 28, 2008 (gmt 0)

10+ Year Member



Yep, just the one page it's going on.

swa66

12:33 am on Oct 29, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Looking at the above the "32" probably needs to be "32px", only "0" is ok without a measure in most css expressions

terrybarnes

9:18 am on Oct 29, 2008 (gmt 0)

10+ Year Member



yes, I noticed that and you're right I had to make that 32px for it to work.