tags:

views:

25

answers:

1

site.css:

a:link, a:visited, a:hover, a:active
{
    color: #0033CC;
    text-decoration: none;
}

in page:

<a href="/foo/boo">test link</a>

jQuery:

$('a').button();

jQuery nicely creates a button for the 'test link' but some text colors on button's different states are the ones defined in site.css, not jQuery theme's.

So the point here is to provide some default look for all the links on the page without affecting jQuery's theming. What am I doing wrong?

A: 

It's working as intended, by specifying it in page it's taking priority over jQuery's definiton.

http://www.w3schools.com/css/css_howto.asp

Generally speaking we can say that all the styles will "cascade" into a new "virtual" style sheet by the following rules, where number four has the highest priority:

  1. Browser default
  2. External style sheet
  3. Internal style sheet (in the head section)
  4. Inline style (inside an HTML element)

If you want you can change your code to:

Javascript:

$("button").button();

HTML:

<button>Button label</button>
Robert
I've double-checked: `site.css` is included **before** `jquery-ui-1.8.2.css` with link-tags in the HEAD section. Shouldn't jQuery's CSS override then those link styles? Changing it to a button is not an option since they are actually links to somewhere. I'll update the link to be more meaningful.
randomguy
It won't change the `<a>` tag with that script, just style it. For example, the demonstration above would look like `<button class="ui-button ui-widget ui-state-default ui-corner-all ui-button-text-only" role="button" aria-disabled="false"><span class="ui-button-text">Button label</span></button>`
Robert
Also, there's no need for the `<a>` tag, just use `<button onclick='window.location="http://www.google.com";'>Go to Google</button>`
Robert
That button relies on Javascript. See, for instance, why this might be a problem: http://stackoverflow.com/questions/3334773/is-progressive-enhancement-a-current-issue-anymore
randomguy
jQuery is Javascript, just a library that makes things more simple and aids in cross-platform scripting. No matter what you do with it, it's going to rely on Javascript.
Robert