Different Color Links on the Same HTML Page

后端 未结 5 2004
傲寒
傲寒 2020-12-30 09:08

Hi I am trying to have different color links on the same page. I want some links to be blue and some links to be black. I am new to html and CSS so thank you in advance!

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-30 09:17

    You need some way to specify which links should have which style, and there are seveal to choose from. Some examples:

    All links that is within the element with id="Main" are black:

    #Main a { color: #000; }
    

    All links that is within any element with class="Message" are blue:

    .Message a { color: #00f; }
    

    All links that themselves have class="command" are black:

    a.command { color: #000; }
    

    All links that are within a li element are dark blue:

    li a { color: #009; }
    

    You can also specify style directly for a specific link.

    
    

提交回复
热议问题