Home > Web Front-end > HTML Tutorial > Questions about repeated CSS definition_html/css_WEB-ITnose

Questions about repeated CSS definition_html/css_WEB-ITnose

WBOY
Release: 2016-06-24 12:13:10
Original
1341 people have browsed it

If the styles for UL and LI have been defined in the external CSS file:



Then on the current page, I will define another style and apply it to the

  • , is it invalid?


    Reply to discussion (solution)

    External css style and internal css style exist at the same time, and the internal css style shall prevail.
    The internal css style and the style attribute of the tag exist at the same time, and the style of the style attribute shall prevail.

    The situation you mentioned should be that both will be valid, but the CSS class has a higher priority. If the same style attribute exists, the style defined in the CSS class will override the ul li style.
    CSS priority: http://spemoon.github.com/blog/2011/09/06/css-priority/

    In the situation you mentioned, both should be valid, but CSS Classes have higher priority. If the same style attributes exist, the styles defined in the CSS class will override the ulli style.
    CSS priority: http://spemoon.github.com/blog/2011/09/06/css-priority/

    I define it in external CSS like this:

    ul#navmenu li:hover li a,ul#navmenu li.iehover li a {  float: none;  background:#6699CC;   color:#FFFFFF;  border-bottom:#FFFFFF solid 1px;  text-align:left;   padding-left:10px;   width:180px; }ul#navmenu li:hover li a:hover,ul#navmenu li:hover li:hover a,ul#navmenu li.iehover li a:hover,ul#navmenu li.iehover li.iehover a {  background:#99CC00;   color:#FFFFFF;}
    Copy after login


    Define it again on the page:
    <style>style2{    background:#000000;}</style>
    Copy after login


    Then quote it like this:

    • test

    • test2


    • Why didn’t the first LI successfully reference the style2 style? Or did I write the format wrong?

      .style2{
      background:#000000;
      }

      A period is missing.

      .style2{
      background:#000000;
      }

      A period is missing.

      I fainted and made another stupid mistake. Thank you so much! Distribute points now! ! !

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template