HTML5, CSS3, and JavaScript Fourth Edition

(Ben Green) #1

Chapter 35


ch31 CSS Selectors


Contents


35.1 Tags.......................... 291
35.2 ID............................ 291
35.3 Class.......................... 292
35.4 Pseudo Class..................... 292
35.5 Transitions...................... 292

35.1 Tags


Each of the HTML tags can be used as a selector. body, div, h1, p, etc.


JavaScript can select some elements based on tag.


document.body


35.2 ID


Only one item can belong to a specific ID. If more items have the same ID,
the browser cannot be expected to do what you want. Consider using a
class.


JavaScript can select a particular item based on its ID.


document.getElementById(’abc’)


291

Free download pdf