I am trying to target an element <a title="next"> which is generated by the server without any class or id tag. I have tried the [title] atribute selector but this selects a number of objects on the page and I only want to select this one. I tryed targeting it like this:- body div a[title] Code (markup): But again this picks up a number of simlar objects on the page. How would I select the <a title="next"> object? snippet from page <page> <div> <a title="Next" href="/wapprivate/wapLocationSetSearch.do?move=Next">Next</a> <div> <div id="quickNav"> <div class="controls"> //lots more code with using the <a title="xxxxx"> tag HTML:
if you want to select just one link (A tag), you can use jquery: $(document).ready( function() { $("a:eq(0)").css("border", "1px solid black"); }) Code (markup): It selects the first A element in the body section of your html file and sets the style for it. Hope it helps, Peter
but if you want to select all links titled by Next use: $("a[title]=Next").css("border", "1px solid black");
Piotr has hit the nail on the head - the only way you can do this in a robust manner that is compatible throughout browsers is through JQuery.
Perhaps you've tried this already, but extending your original example to include the targetted title value of "Next" ... body div a[title="Next"] Code (markup): Note that Attribute Selectors don't work in IE6 or earlier.
try to style tags by title attribute look like bad idea, have you have a lot of title need to be styled? so create hundreds of wasting css code lines? why dont try class attribute? or css DOM?
siothach is correct - its a really bad way of doing this. Is there no way you can edit the output to put ID's or CLASS attributes on the DIV's? How are the pages produced, Via a CMS?
Thanks for all the feedback. To answer the question no there is no way of getting the server to push the code with class or ID. I dont really want to have to use JS or Jquery. It is just the one title tag I am trying to effect not lots of different ones. So for me the solution was body div a[title="Next"] Code (markup): cheers