- Mastering CSS
- Rich Finelli
- 152字
- 2021-07-08 09:45:53
IDs
Scroll up to the top of our site, and in our HTML, go to h1:

Let's give the first h1 tag a special ID called main-site-title:
<h1 id="main-site-title">Old Chompy</h1>
With an ID, you can also use whatever name you want inside the quotes as long as it's meaningful. Switch over to the CSS and scroll down to just underneath our alt-headline class. This is where we'll add main-site-title. The main difference between writing classes and IDs is we start classes with a period and IDs with a number sign or pound sign or a hashtag (whatever you want to call it):
#main-site-title
In this case, we'll then say the color is different: deep pink. Save this and refresh the site to see the effect:
#main-site-title{ color: deeppink; }
Following is the output of preceding code:

You can see that this changes just the Old Chompy h1, the one that has the ID.
推薦閱讀
- Mastering Entity Framework
- JIRA 7 Administration Cookbook(Second Edition)
- Java FX應(yīng)用開發(fā)教程
- 實(shí)戰(zhàn)Java程序設(shè)計
- C語言程序設(shè)計教程(第2版)
- INSTANT CakePHP Starter
- Learn WebAssembly
- Python高效開發(fā)實(shí)戰(zhàn):Django、Tornado、Flask、Twisted(第2版)
- JS全書:JavaScript Web前端開發(fā)指南
- Learning R for Geospatial Analysis
- Machine Learning With Go
- Clojure for Java Developers
- HTML+CSS+JavaScript網(wǎng)頁制作:從入門到精通(第4版)
- Hack與HHVM權(quán)威指南
- SFML Game Development