Language
日本語
English

Caution

JavaScript is disabled in your browser.
This site uses JavaScript for features such as search.
For the best experience, please enable JavaScript before browsing this site.

CSS Dictionary

  1. Home
  2. CSS Dictionary
  3. [CSS Selector] E#idName

[CSS Selector] E#idName

Using #id-name, you can apply styles to the element with the specified id.

Sample Code

style.css
/* target by id */
#hoge { color: red;}

/* target by tag + id */
p#hoge1 { color: blue;}

/* practical use: major page sections */
#header { background-color: #2c3e50; color: white; padding: 16px;}
#main { max-width: 1200px; margin: 0 auto; padding: 24px;}
#footer { background-color: #34495e; color: #ecf0f1; padding: 24px; text-align: center;}

/* id is also used as an anchor for in-page links */
#section-top { scroll-margin-top: 60px;} /* offset for sticky headers */

Browser Display Result

#hoge { color: red;} /* Applies to the element with id 'hoge'. */
p#hoge1 { color: blue;} /* Applies to the p element with id 'hoge1'. */

<div id="hoge">This is a div element with id 'hoge'.</div>
<div>This is a div element.</div>
<p id="hoge1">This is a p element with id 'hoge1'.</p>
<p>This is a p element.</p>

Browser Compatibility

Chrome Chrome
1+
Firefox Firefox
1+
Safari Safari
1+
Edge Edge
12+
IE IE
11
10
9
8
7
6
Opera Opera
3.5+
2 and earlier ×
iOS Safari iOS Safari
1+
Android Android Browser
4.4+
3 and earlier ×
Chrome Android Chrome Android
Latest
Same support as desktop
Firefox Android Firefox Android
Latest
Same support as desktop

※ Version data is based on MDN.

If you find any errors or copyright issues, please .