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>



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.

  • Chhers Phil B, appreciate the informative response! – Daft Jun 18 '14 at 8:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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