HTML(2)

Linking from “lounge.html” to the external stylesheet

<html>
<head>
<meta charset="utf-8">
<title>Head First Lounge</title>
<link type="text/css" rel="stylesheet" href="lounge.css">
<style>
</style>
</head>

You don’t need the <style> element anymore—just delete it.The rel attribute specifies the relationship between the HTML file and the thing you’re linking to. We’re linking to a stylesheet, so we use the value “stylesheet”.And the stylesheet is located at this href (in this case, we’re using a relative link, but it could be a full-blown URL).<link> is a void element.It has no closing tag.

inheritance

To override the font-family property inherited from body, add a new rule selecting em with the font-family property value set to serif.

class

To add an element to a class, just add the attribute “class” along with the name of the class.

p.greentea {color: green;}now you have a way of selecting <p> elements that belong to a certain class to style them.

If you want all elements that are in the greentea class to have a style, then you can just write your rule like this:
.greentea {
color: green;
}

how styles are applied

First, do any selectors select your element?If there is, and it has a font-family property and value,

then that’s the value for your element.If there are no selectors that match your element, then you rely on inheritance.

If your element doesn’t inherit the value from any of its ancestors, then you use the default value defined by the browser.

What if multiple selectors select an element?if one rule is more specific than the others, then it wins.

When equal specificity. What do you do now? You choose the one that is listed last in the CSS file.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值