- 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.
推薦閱讀
- Learning RxJava
- Mastering Selenium WebDriver
- BeagleBone Media Center
- 數(shù)據(jù)結(jié)構(gòu)簡明教程(第2版)微課版
- 你必須知道的204個Visual C++開發(fā)問題
- Python 3破冰人工智能:從入門到實戰(zhàn)
- MySQL數(shù)據(jù)庫管理與開發(fā)(慕課版)
- Building an RPG with Unity 2018
- Flutter跨平臺開發(fā)入門與實戰(zhàn)
- 組態(tài)軟件技術(shù)與應(yīng)用
- Julia高性能科學(xué)計算(第2版)
- Mastering C++ Multithreading
- 運維前線:一線運維專家的運維方法、技巧與實踐
- 并行編程方法與優(yōu)化實踐
- Practical GIS