Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

    width: 100px;
    height: 115px;
    margin-right: 15px;

    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>


share|improve this question
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 '14 at 8:47

Your Answer


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.