Jump to content

<A> Using Onclick="" Ignore Css Formatting


DarkxPunk

Recommended Posts

The default link formatting (blue with underline) is given to links that have the HREF attribute. Give your link an HREF attribute and it will style normally. If your link doesn't require an HREF attribute then maybe there's another element that's better for the task, like <button> or <input type="button">.

Link to comment
Share on other sites

You can use any element you like. But you're going to have to set the color to blue and give it an underline with CSS yourself.

a {  color: blue;  text-decoration: underline;}

The browser only styles, by default, the links that have an HREF attribute. If it doesn't then you have to style it manually.

Link to comment
Share on other sites

What's wrong with using the button tag? You can style it as you wish
I'm not sure, but it may be block level by default.
There must be a way other than button or input. I simply want a plain text button that caries out a javascript function but has a css style.
use <span>
Link to comment
Share on other sites

You can use any element you like. But you're going to have to set the color to blue and give it an underline with CSS yourself.
a {  color: blue;  text-decoration: underline;}

The browser only styles, by default, the links that have an HREF attribute. If it doesn't then you have to style it manually.

Okay so if I understand correctly. In CSS if I style <a> it will only come into effect if it follows as so <a href=""></a>; otherwise it ignores the styling. Now just my opinion but, that is stupid. If I style <a> it should style <a onclick=""> and any other combination, not only <a href="">.
use <span>
That is a good idea... Truly never thought of it.
What's wrong with using the button tag? You can style it as you wish
Now with using the button tag, I am not too familiar with it, nor do I know how to style it to simply display as text and not a 'button'. I am assuming you can't do it though... To summarize. I will go with the span idea! Peace
Link to comment
Share on other sites

No, I didn't say styles are ignored for the <a> element. I'm saying that the browser's default style (underlined and blue) only applies to links with an href attribute. Any element is clickable, it just won't have the same cursor as the <a> element does. This can be changed by setting the CSS of the element:span { cursor: pointer; }

Link to comment
Share on other sites

No, I didn't say styles are ignored for the <a> element. I'm saying that the browser's default style (underlined and blue) only applies to links with an href attribute. Any element is clickable, it just won't have the same cursor as the <a> element does. This can be changed by setting the CSS of the element:span { cursor: pointer; }
I found my problem with why span would not work. I will continue to get everything working. Thanks for all the help everyone.
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...