官术网_书友最值得收藏!

External style sheets

Currently, we write our rule sets in an external style sheet. You can see it's literally its own file:

In the folder structure on the left-hand side of the screen, you can see that it's in a folder called css:

Besides external style sheets, there are also inline and embedded style sheets. The external style sheet is by far the best place to write your styles; it's a separate file that is linked to each HTML page. An external style sheet can control a whole website, which is the main reason why this is the preferred type of style sheet. Anywhere in between the <head></head> tags of your index.html file; this is where you can link to your external style sheet:

<head>
<link rel="stylesheet" href="css/style.css">
</head>

The href attribute points to the location of the file. Here it's pointing to the css folder and then a file called style.css. There's also a rel attribute that just basically says that this is a stylesheet. In the past, you might have seen text/css as the value for the type attribute, as shown in the following code block, but that is no longer necessary in HTML5:

<head>
<link rel="stylesheet" href="css/style.css" type="text/css">
</head>

You may have also seen a closing forward slash on a self-closing tag like the link element, but in HTML5 that forward slash is no longer necessary. So including it or excluding it won't have any impact on your site.

主站蜘蛛池模板: 铁岭县| 四平市| 仁怀市| 揭阳市| 正镶白旗| 聂拉木县| 时尚| 樟树市| 玉山县| 石阡县| 沾益县| 景泰县| 万全县| 邳州市| 湖北省| 那坡县| 简阳市| 红原县| 丰都县| 汉中市| 阜城县| 阿克苏市| 微博| 类乌齐县| 霍州市| 武川县| 贺兰县| 青海省| 商洛市| 应城市| 治多县| 资溪县| 固阳县| 黎平县| 文登市| 安龙县| 凤城市| 大关县| 镇沅| 高州市| 安图县|