开发者

Can element selector be declared in external css?

开发者 https://www.devze.com 2023-02-11 03:49 出处:网络
The following selector is declared in external stylesheet p:first-letter { color: red; } But it doesn\'t make the first letter in <p> element turn red. It does work wh开发者_运维问答en this i

The following selector is declared in external stylesheet

p:first-letter
{
  color: red;
}

But it doesn't make the first letter in <p> element turn red. It does work wh开发者_运维问答en this is declared in internal css.


Yes it can.

What you wrote should work just fine; are you sure you are linking to the external stylesheet correctly?


This works perfectly fine for me in Firefox 3.6.x:

external-selector.htm

<!DOCTYPE html>
<html lang="en">
    <head>
        <link rel="stylesheet" href="external-selector.css" type="text/css">
        <style type="text/css">
            p { color: blue; }
        </style>
    </head>
    <body>
        <p>Paragraph!</p>
    </body>
</html>

external-selector.css

p:first-letter {
    color: red;
}

output

Can element selector be declared in external css?


I had this problem as well, and after over an hour of messing with Firefox I figured out that it's the InvisibleHand addon that is causing this problem for me. When I disabled it, the problem went away.

I have emailed their info email address asking them to fix the bug.


it seems any other CSS is conflicting.

try if it work

p:first-letter
{
 color: red !important; 
}


I had the same problem described here. I knew the external stylesheet was being applied because I could see other styles being applied. After reading Heptite's answer I decided I'd try updating Firefox. This fixed the problem.

So, perhaps this was a bug that got fixed in the latest Firefox (v39.0)

0

精彩评论

暂无评论...
验证码 换一张
取 消