Css/Training/Selectors - W3C Wiki
- CSS Educational Materials
- Week 1
- Introduction to CSS
- What is CSS
- Syntax
- Selectors
- Create CSS
- Introduction to CSS
- Week 1
Selectors are specify the target of styling. Selectors may range from simple element names to rich contextual representations.
Kind of selector
Type selector
A type selector is the name of HTML Tag.
[index.html]
<p>This is a paragraph</p> <p>This is a paragraph</p> <p>This is a paragraph</p>[style.css]
p{ color: red; font-size: 12px; }Class selector
Class selector is used for one or more elements. It is described the value of class attribute of HTML document with ".(period)".
[index.html]
<p class="red">This is a paragraph</p> <p class="blue">This is a paragraph</p> <p class="red">This is a paragraph</p> <p class="blue">This is a paragraph</p>[style.css]
p{ font-size: 12px; } .red{ color: red; } .blue{ color: blue; }ID selector
ID selector is used for unique element. It is described the value of ID attribute of HTML document with "#".
[index.html]
<p class="red">This is a paragraph</p> <p class="blue">This is a paragraph</p> <p class="red" id="small">This is a paragraph</p>[style.css]
p{ font-size: 12px; } .red{ color: red; } .blue{ color: blue; } #small{ font-size: 9px; }Descendant combinator
A descendant combinator is whitespace that separates two sequences of simple selectors. A selector of the form "A B" represents an element B that is an arbitrary descendant of some ancestor element A.
[index.html]
<h1>This is a <em>header</em></h1> <p>This is a <em>paragraph</em></p>[style.css]
h1 em{ color: red; font-size: 12px; }The selector introduces here is not all. See also Selectors Level 3.
Grouping
A comma-separated list of selectors represents the union of all elements selected by each of the individual selectors in the list.
[index.html]
<h1>This is a heading</h1> <h2>This is a heading</h2> <h3>This is a heading</h3> <h4>This is a heading</h4>[style.css]
h1, h2, h3, h4{ color: red; font-size: 12px; }Let's try to creating CSS!
Từ khóa » H1 H2 P Css
-
HTML H1 To H6 Tag - W3Schools
-
–
: The HTML Section Heading Elements - MDN - Mozilla
-
What Are The Default CSS Styling Of Heading Tags? (H1, H2, H3, H4, H5)
-
6 Selectors
-
Heading Tags (H1, H2, H3, P) In HTML - Accessibility At Penn State
-
HTML And CSS: The Basics - GitHub Pages
-
[PDF] 1. Write The Correct CSS To Center All H1 And H2 Headings.
-
HTML And CSS Tutorial - Nanyang Technological University
-
Typography · Bootstrap V5.0
-
H2 P In Css Code Example
-
Discussions And Answers - Department Of Computer Science
-
How To Style Text Elements With Font, Size, And Color In CSS
-
How To Prevent A Line Break With An H1, H2, H3 Tag - Ironpaper
-
Add Two New Type Selectors (h1 And H2). Use The Font-size Property ...