简体   繁体   中英

CSS code in HTML no effect

I write the code in Notepad and execute by Chrome, but I don't see the color appaear,

http://i.imgur.com/RJHb2Xp.png

it seems that the CSS part of code doesn't take effect, what should I do to let the CSS part take effect?

<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>TITLE</title>
        <style type="text/css">
            body {background:white; color:black}
            a:link {color:red}
            a:visited {color:green }
            a:active {color:blue}
        </style>
    </head>
    <body>
        <h1>B blue T Black</h1>
    </body>
</html> 

<h1> is not an <a href=""> so none of your a: styles will apply, only body { color: black; } body { color: black; } will be applied, that's why your text is black.

Replace your a: rules with a single h1 rule or replace the <h1> with <a href="#"> .

you can try this one:

<!doctype html>
<html>
    <head>
        <meta charset="utf-8">
        <title>css</title>
        <style type="text/css">
            body {background-color:white; }

h1 
{
color:red;
}
        </style>
    </head>
    <body >

        <h1>B blue T Black</h1>
    </body>

Your header is not a link. Your CSS is set up properly, it's just that there are no links to be styled. Wrap your tag with an and you should be good to go!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM