How would I get inline style links to work?

My Code: https://jsfiddle.net/uao4gfow/4/

How would I get inline style links to work?

I don’t think the way I have it set up is right.

<a href="http://www.yahoo.com" style a:link="color:#33348e; text-decoration: none;" a:visited="color:#33348e; text-decoration: none;" a:hover="color:#33348e; text-decoration: none;" a:active="color:#7476b4; text-decoration: underline;"> here</a>

No.

It can be simplified

a:link
, a:visited
, a:hover {
 color:#33348e;
 text-decoration: none;
}
a:active {
color:#7476b4;
text-decoration: underline;
}
.......
<a href="http://www.yahoo.com"> here</a>

If you needed to, you could give the anchor element an id or a class.
But it will probably be adequate and better to use DOM selectors if you need that one to be different from other links in the page.

Your syntax is wrong. I don’t think it is possible to use pseudo classes such as :hover in inline styles. Why do you want to use inline styles here? Do you have a stylesheet where you can put these styles? … But @Mittineague beat me to it and he has the solution for you without inline styles.

Yes, but I’m unsure if text-decoration for visited will work. That has been known to be a risk vector for a long time and I imagine most browsers have restrictions in place.

You will still be able to visually style visited links, but you’re severely limited in what you can use. We’re limiting the CSS properties that can be used to style visited links to color, background-color, border-*-color, and outline-color and the color parts of the fill and stroke properties. For any other parts of the style for visited links, the style for unvisited links is used instead. In addition, for the list of properties you can change above, you won’t be able to set rgba() or hsla() colors or transparent on them.

1 Like

You won’t.

Pseudo classes (and pseudo elements) are not available using inline styling.

Pseudo-classes classify elements on characteristics other than their name, attributes or content; in principle characteristics that cannot be deduced from the document tree.

You have been told a number of times now not to use inline styling but you still continue to do so (without qualifying why you think this approach is required) and as you see you run into issue after issue. CSS is not meant to be wholly used in the way that you are using it. It is pointless for you to continue with this approach as it is unmanageable and unmaintainable and goes against all best practices.

The only reasons to use inline styles were for example if you have a CMS that only allowed ‘small’ changes via inline styling (I believe ebay used to allow inline styling only for users selling products). Or perhaps if you have JS modifying some CSS property on the fly. Otherwise just don’t do it. :slight_smile:

CSS is meant to be kept out of the mark up as that was its prime purpose to separate content from presentation.

4 Likes

This works:

body vlink="red"> <body alink="green"> <body text="blue">
<a href="" target="_blank" style="background-color:black">Main page</a>Blue
</body>

How can it work when you have 3 <body> tags???

2 Likes

They are not inline style links they are deprecated html attributes and nothing to do with css as such. I still don’t understand why you are researching code from the last century? It makes no sense when there is such an easy and valid alternative.

Why are you happy to add deprecated html attributes to the body element yet refuse to use external css? Your body attributes will style all links and you cannot target specific elements as you can when using css properly.

5 Likes

@asasass

What is the reason for your intransigence ?

@members

What is the reason for your perseverance?

I trust, that the powers that be will not find
my questions unreasonably offensive. :sunglasses:

coothead

7 Likes

Which version of Netscape are you using - Netscape 4 was the last browser in which that HTML 2 code would have been expected to work even if you’d got the code right with just the one body tag. Since about 1995 there have been far superior ways to achieve that result and I would be very surprised if your code worked in any modern browser that is properly configured.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.