Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

Does the 'Id' attribute work the same for apex elements as it does for html elements?

The anchor tag below, gets the background image, but the outputlink does not.

Am I doing somthing wrong? Can this be fixed?

.dm_lp_imgs{
    width: 100px;
    float:left;
    height: 115px;
    margin-right: 15px;
} 


#myId{
    background: url('{! URLFOR($Resource.folder, 'imgs/image.png') }') left top no-repeat;
}


<apex:outputLink id="myId" styleClass="dm_lp_imgs" target="_top" value=""> </apex:outputLink>


<a id="myId" class="dm_lp_imgs"></a>

Cheers!

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Apex tags automatically generate strings for the IDs unless all of the parent DOM structure have IDs defined as well. In that case it would be something like bodyID:formID:elementID. For this scenario I'd suggested using a class for your CSS as its best practice anyway.

share|improve this answer
    
Chhers Phil B, appreciate the informative response! –  Daft Jun 18 at 8:47

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.