Three kinds of CSS style - inline, embedded, outside

Insert the HTML file from the CSS style code inserted in the form of view can be divided into three forms: inline styles, embedded style, external style.

Inline styles: CSS style is to write HTML tags at the beginning of the

< style="color:#CCC;">这里式设置了#CCC颜色的字</style>

Embedded styles: CSS style written between style tags

    < style type="text/css">
        p {
            font-size: 17px;
        }
    </style>

Embedded CSS style must be written in between, and usually written between inline style

External CSS style-type: is to write CSS code in a separate external file, the CSS file extension .css suffix is used in the label tag to link the CSS style file into HTML file

<link href="main.css" rel="stylesheet" type="text/css" />
Remarks:
  1. CSS style file names of the letters in a meaningful name, such as: index.css
  2. rel = "stylesheet" type = "text / css" fixed wording can not be modified
  3. The general location of the tag within a tag
Three kinds of insert-style-priority:

Three kinds of insert style in the end is a high priority from: inline> Embedded> External formula
wherein Embedded> external conditions formula: embedded CSS position behind the external type
can be understood as: the principle of proximity - are isolated set elements closer higher priority

!important

You can use style settings for some of the highest authority in certain special circumstances! Important to handle

    p {color: #DDD!important;}

In addition browsers also have a default style to display a web page, the user can set the style pages themselves, the priority of these styles are:
! Browser's default style> Web producers style> Users set up their own style> set important style .

Guess you like

Origin www.cnblogs.com/dyfblogs/p/11391655.html