SlideShare ist ein Scribd-Unternehmen logo
1 von 9
Downloaden Sie, um offline zu lesen
Beginner CSS Tutorial: Class and ID Selectors                                                               1




I. OVERVIEW OF CLASSES AnD IDs

Class Selectors can be used to select any html element that has been given a class attribute. For in-
stance, a class can be applied to multiple things within your html document. Think of it as a paragraph
style in InDesign.

Classes are defined in CSS with a “.” For instance:

.intro {
    font-weight: bold;
}




ID Selectors are similar to class selectors, in that they can be used to select any html element that has
an ID attribute. However, an ID can only be used OnCE within a document, whereas Classes can
be used as often as needed. IDs are used for specific instances. Think of an ID as a character style in
InDesign.

IDs are defined in CSS with a “#” For instance:

#main_nav {
    font-weight: bold;
}




When do you use ID or Class? Classes can be used as many times as needed within a document. IDs
can be applied only once within a document. If you need to use the same selector more than once,
classes are a better choice.

However, IDs have more weight than classes. If a class selector and an ID selector apply the same
property to one element, the ID selector’s value would be chosen. For example the following #ID
selector:

h2#intro {
    color: red;
}

will override the following .Class selector:

h2.intro {
    color: blue;
}

This is the real concept behind “cascading”... that there is hierarchy built into the language of CSS so
that certain rules “override” others.
II. WORkIng WITH CLASSES AnD IDS                                                                      2


1. Make a folder on your desktop. Call it “CSS_tutorial_2”

2. Create a new file in Dreamweaver. Select:

    - blank page
    - Page type: html
    - Layout: <none>
    - In lower right, for “DocType” select “strict”
    - click “create”




Again, we do not want to use a template for this because we are building the CSS from scratch.

3. go to “File” > “Save as” and name your Dreamweaver document “class_id_selectors_2.html”. Save it
   in your “CSS_tutorial_2” folder on your desktop.

4. Look at the upper left-hand corner of your screen. There are three buttons:

“Code”, “Split”, and “Design”. Click on “Split”.
5. Look at line 5 of the code:                                                                               3


         <title>Untitled Document</title>
Type in a name for your page. Again, you can do this in the top window:




6. In the “design” section of your workspace, type in the following content:

This is my paragraph tag.

This is my class selector.

This ID selector overrides my class and paragraph selectors.


III. REVIEW FOR HOW TO SAVE A CSS FILE AnD DEFInIng RULES

1. Look at your screen. In the upper right-hand corner, there should be a panel called “CSS Styles”. It
   looks like this:

                                                   In the upper right-most corner of that panel, click and
                                                   hold on this icon.

                                                   And drag down to “new”. now, you should get a win-
                                                   dow that looks like this:
2. You are adding a new CSS rule to your document. Do the following:                                        4


         - Selector Type: select “Tag” (we’ll making Classes and IDs after).

         - Tag: click and hold the two arrows to the right of the field. Drag down to select “p”.
           You are defining the “p” (paragraph) tag.

         - Define in: select “(new Style Sheet File)”

         - click “Ok”




3. Save your styles before defining any rules. name your CSS file: “class_id_selectors_2.css” and save it
in your “CSS_tutorial_2” folder. You will only have to do this once. The next time we add a rule, it will
be much easier.

4. Once your “class_id_selectors_2.css” is saved, a window will automatically pop up. Save it with the
following definitions (Only set the following rules for the type category. Don’t worry about the other
categories yet).
5. now you should have a <p> defined in your style sheets window. now, highlight the text you wrote    5

in the design window. At the bottom, in the properties window, select the “format” pulldown menu at
the far upper left and select “paragraph”. This makes all your text formatted with the <p> tag.




Look in the code view—your html should look like this:

<body>
          <p>This is my paragraph tag.</p>
          <p>This is my class selector.</p>
          <p>The ID selector overrides my class and paragraph selectors.</p>
</body>
</html>




And the design view should look like this:




now let’s start applying classes and IDs to this content.



IV. CREATIng RULES FOR CLASSES

1. In the CSS window, underneath properties, click on the page + icon. (new CSS rule) Select “class”
radial button (at the top) and name the new rule “p_class”. Make sure that the bottom radial button
reads as “define in: class_id_selectors_2.css”.
2. In the CSS rules definition window, select OnLY the following: (right now we are only going to             6

change the weight and the color of the font.) Click ok.




3. In the design view, highlight the text that reads “This is my class selector.” In the properties window,
look to the far left to the pulldown menu that reads “Format: Paragraph”. To the right of that menu is
another pulldown menu that reads “Style.” In the “style” pulldown menu you should now see an op-
tion to select “p_class”. Once you have selected it, see your text change to bold and a dark purple color.




notice how your class selector changed the color and weight of the text, but nOT the font! This is
because we didn’t change the font... it automatically picks up on the specifications of the original <p>
tag you defined, unless you define it otherwise. This is the beauty of cascading style sheets! (You can
always go back and change the font, border, color, etc. etc...)
4. Let’s take a look at what your html is doing here:                                                       7


<body>
<p>This is my paragraph tag.</p>

<p class=”p_class”>
This is my class selector.
</p class>

<p>The ID selector overrides my class and paragraph selectors.</p>

</body>
</html>

Here’s what the html mark-up is saying: this class belongs to the <p> tag, and it’s called “p_class”. All
the text in between belongs to the <p> tag, but apply the class properties to it.



5. Here’s what your CSS file should look like:

@charset “UTF-8”;

p {
          font-family: Arial, Helvetica, sans-serif;
          font-size: 12px;
          font-weight: normal;
          color: #993300;
}

.p_class {
          font-weight: bold;
          color: #663366;
}



It makes sense, correct? notice the class definition begins with a “.” now let’s move on to IDs.



V. CREATIng RULES FOR IDs

1. In the CSS window, underneath properties, click on the page + icon. (new CSS rule) Select “Ad-
vanced: IDs, pseudo-class selectors” radial button (at the top) and name the new rule “#p_id”. Make
sure that the bottom radial button reads as “define in: class_id_selectors_2.css”.
2. In the CSS rules definition window, select OnLY the following: (right now we are going to change        8

the font, case, and color.) Click ok.




3. In the design view, highlight the text that reads “This is my class selector.” Look in the properties
window, to the pulldown menu “Style.” notice there is no option to select “#p_id”... This is because
you can only use an ID once! Let’s write the mark-up for this, as it’s not easy to apply this change in
the Dreamweaver interface.

In your html mark-up, key in the following (in pink):

<body>

<p>This is my paragraph tag.</p>

<p class=”p_class”>
This is my class selector.</p class>

<p id=”p_id”>
The ID selector overrides my class and paragraph selectors.</p id>

</body>
</html>

You are telling the <p> tag that this ID belongs to it, and it’s called “p_id”. All the text in between
belongs to the <p> tag, but applies the ID properties to it. You can only use this once in your
document. Here’s what your text looks like now:
4. Here’s what your CSS file should look like:                                                           9


@charset “UTF-8”;

p {
          font-family: Arial, Helvetica, sans-serif;
          font-size: 12px;
          font-weight: normal;
          color: #993300;
}

.p_class {
          font-weight: bold;
          color: #663366;
}

#p_id {
          font-family: Georgia, “Times New Roman”, Times, serif;
          text-transform: uppercase;
          color: #006633;
}

notice the following:

- the ID definition begins with a “#”

- the ID it doesn’t define the type size. This information from the original <p> tag.

- the semi-colon (;) after each rule.



next, we will move onto divs. Divs are containers. This is where things really get exciting as you are
able to define “chunks” for your layout!

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (17)

Web Typography
Web TypographyWeb Typography
Web Typography
 
CSS Foundations, pt 2
CSS Foundations, pt 2CSS Foundations, pt 2
CSS Foundations, pt 2
 
HTML Foundations, pt 3: Forms
HTML Foundations, pt 3: FormsHTML Foundations, pt 3: Forms
HTML Foundations, pt 3: Forms
 
Web Layout
Web LayoutWeb Layout
Web Layout
 
Advanced Cascading Style Sheets
Advanced Cascading Style SheetsAdvanced Cascading Style Sheets
Advanced Cascading Style Sheets
 
Unit 3 (it workshop).pptx
Unit 3 (it workshop).pptxUnit 3 (it workshop).pptx
Unit 3 (it workshop).pptx
 
Pfnp slides
Pfnp slidesPfnp slides
Pfnp slides
 
Make Css easy(part:2) : easy tips for css(part:2)
Make Css easy(part:2) : easy tips for css(part:2)Make Css easy(part:2) : easy tips for css(part:2)
Make Css easy(part:2) : easy tips for css(part:2)
 
Web Design Assignment 1
Web Design Assignment 1 Web Design Assignment 1
Web Design Assignment 1
 
Css
CssCss
Css
 
Css
CssCss
Css
 
Tags
TagsTags
Tags
 
3 css essentials
3 css essentials3 css essentials
3 css essentials
 
Web development (html)
Web development (html)Web development (html)
Web development (html)
 
Introduction to whats new in css3
Introduction to whats new in css3Introduction to whats new in css3
Introduction to whats new in css3
 
Ms word 2013
Ms word 2013Ms word 2013
Ms word 2013
 
Css tutorial
Css tutorialCss tutorial
Css tutorial
 

Andere mochten auch

Aconcagua 2010
Aconcagua 2010Aconcagua 2010
Aconcagua 2010NFS
 
Informanten Efterår 06
Informanten Efterår 06Informanten Efterår 06
Informanten Efterår 06Jonas Sindal
 
Iisec dt-2011-10
Iisec dt-2011-10Iisec dt-2011-10
Iisec dt-2011-10PaolaReyesR
 
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>tutorialsruby
 

Andere mochten auch (7)

Aconcagua 2010
Aconcagua 2010Aconcagua 2010
Aconcagua 2010
 
Informanten Efterår 06
Informanten Efterår 06Informanten Efterår 06
Informanten Efterår 06
 
HTML Resources
HTML ResourcesHTML Resources
HTML Resources
 
tut0000021-hevery
tut0000021-heverytut0000021-hevery
tut0000021-hevery
 
Iisec dt-2011-10
Iisec dt-2011-10Iisec dt-2011-10
Iisec dt-2011-10
 
newsletter53
newsletter53newsletter53
newsletter53
 
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
TopStyle Help &amp; &lt;b>Tutorial&lt;/b>
 

Ähnlich wie Beginner CSS Tutorial: Class and ID Selectors Guide

Ähnlich wie Beginner CSS Tutorial: Class and ID Selectors Guide (20)

CSS_tutorial_1
CSS_tutorial_1CSS_tutorial_1
CSS_tutorial_1
 
Web topic 15 1 basic css layout
Web topic 15 1  basic css layoutWeb topic 15 1  basic css layout
Web topic 15 1 basic css layout
 
TIBCO General Interface - CSS Guide
TIBCO General Interface - CSS GuideTIBCO General Interface - CSS Guide
TIBCO General Interface - CSS Guide
 
Css notes
Css notesCss notes
Css notes
 
Customizing the look and-feel of DSpace
Customizing the look and-feel of DSpaceCustomizing the look and-feel of DSpace
Customizing the look and-feel of DSpace
 
BasicCSSFlowTutorial
BasicCSSFlowTutorialBasicCSSFlowTutorial
BasicCSSFlowTutorial
 
BasicCSSFlowTutorial
BasicCSSFlowTutorialBasicCSSFlowTutorial
BasicCSSFlowTutorial
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
 
Tutorial5
Tutorial5Tutorial5
Tutorial5
 
Tutorial5
Tutorial5Tutorial5
Tutorial5
 
Introduction to css
Introduction to cssIntroduction to css
Introduction to css
 
Lecture2
Lecture2Lecture2
Lecture2
 
HowTo_CSS
HowTo_CSSHowTo_CSS
HowTo_CSS
 
Html / CSS Presentation
Html / CSS PresentationHtml / CSS Presentation
Html / CSS Presentation
 
CSS Methodology
CSS MethodologyCSS Methodology
CSS Methodology
 
Learn CSS From Scratch
Learn CSS From ScratchLearn CSS From Scratch
Learn CSS From Scratch
 
CSS Foundations, pt 1
CSS Foundations, pt 1CSS Foundations, pt 1
CSS Foundations, pt 1
 
CSS Basic and Common Errors
CSS Basic and Common ErrorsCSS Basic and Common Errors
CSS Basic and Common Errors
 
SMACSS Workshop
SMACSS WorkshopSMACSS Workshop
SMACSS Workshop
 
Fewd week2 slides
Fewd week2 slidesFewd week2 slides
Fewd week2 slides
 

Mehr von tutorialsruby

&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>tutorialsruby
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />tutorialsruby
 
Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269tutorialsruby
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008tutorialsruby
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008tutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheetstutorialsruby
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheetstutorialsruby
 
Winter%200405%20-%20Advanced%20Javascript
Winter%200405%20-%20Advanced%20JavascriptWinter%200405%20-%20Advanced%20Javascript
Winter%200405%20-%20Advanced%20Javascripttutorialsruby
 
Winter%200405%20-%20Advanced%20Javascript
Winter%200405%20-%20Advanced%20JavascriptWinter%200405%20-%20Advanced%20Javascript
Winter%200405%20-%20Advanced%20Javascripttutorialsruby
 

Mehr von tutorialsruby (20)

&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
The Art Institute of Atlanta IMD 210 Fundamentals of Scripting &lt;b>...&lt;/b>
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />&lt;img src="../i/r_14.png" />
&lt;img src="../i/r_14.png" />
 
Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0Standardization and Knowledge Transfer – INS0
Standardization and Knowledge Transfer – INS0
 
xhtml_basics
xhtml_basicsxhtml_basics
xhtml_basics
 
xhtml_basics
xhtml_basicsxhtml_basics
xhtml_basics
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentation
 
xhtml-documentation
xhtml-documentationxhtml-documentation
xhtml-documentation
 
CSS
CSSCSS
CSS
 
CSS
CSSCSS
CSS
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
 
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa0602690047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
0047ecaa6ea3e9ac0a13a2fe96f4de3bfd515c88f5d90c1fae79b956363d7f02c7fa060269
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
BloggingWithStyle_2008
BloggingWithStyle_2008BloggingWithStyle_2008
BloggingWithStyle_2008
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 
cascadingstylesheets
cascadingstylesheetscascadingstylesheets
cascadingstylesheets
 
Winter%200405%20-%20Advanced%20Javascript
Winter%200405%20-%20Advanced%20JavascriptWinter%200405%20-%20Advanced%20Javascript
Winter%200405%20-%20Advanced%20Javascript
 
Winter%200405%20-%20Advanced%20Javascript
Winter%200405%20-%20Advanced%20JavascriptWinter%200405%20-%20Advanced%20Javascript
Winter%200405%20-%20Advanced%20Javascript
 
eng2u3less38
eng2u3less38eng2u3less38
eng2u3less38
 

Kürzlich hochgeladen

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 

Kürzlich hochgeladen (20)

A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 

Beginner CSS Tutorial: Class and ID Selectors Guide

  • 1. Beginner CSS Tutorial: Class and ID Selectors 1 I. OVERVIEW OF CLASSES AnD IDs Class Selectors can be used to select any html element that has been given a class attribute. For in- stance, a class can be applied to multiple things within your html document. Think of it as a paragraph style in InDesign. Classes are defined in CSS with a “.” For instance: .intro { font-weight: bold; } ID Selectors are similar to class selectors, in that they can be used to select any html element that has an ID attribute. However, an ID can only be used OnCE within a document, whereas Classes can be used as often as needed. IDs are used for specific instances. Think of an ID as a character style in InDesign. IDs are defined in CSS with a “#” For instance: #main_nav { font-weight: bold; } When do you use ID or Class? Classes can be used as many times as needed within a document. IDs can be applied only once within a document. If you need to use the same selector more than once, classes are a better choice. However, IDs have more weight than classes. If a class selector and an ID selector apply the same property to one element, the ID selector’s value would be chosen. For example the following #ID selector: h2#intro { color: red; } will override the following .Class selector: h2.intro { color: blue; } This is the real concept behind “cascading”... that there is hierarchy built into the language of CSS so that certain rules “override” others.
  • 2. II. WORkIng WITH CLASSES AnD IDS 2 1. Make a folder on your desktop. Call it “CSS_tutorial_2” 2. Create a new file in Dreamweaver. Select: - blank page - Page type: html - Layout: <none> - In lower right, for “DocType” select “strict” - click “create” Again, we do not want to use a template for this because we are building the CSS from scratch. 3. go to “File” > “Save as” and name your Dreamweaver document “class_id_selectors_2.html”. Save it in your “CSS_tutorial_2” folder on your desktop. 4. Look at the upper left-hand corner of your screen. There are three buttons: “Code”, “Split”, and “Design”. Click on “Split”.
  • 3. 5. Look at line 5 of the code: 3 <title>Untitled Document</title> Type in a name for your page. Again, you can do this in the top window: 6. In the “design” section of your workspace, type in the following content: This is my paragraph tag. This is my class selector. This ID selector overrides my class and paragraph selectors. III. REVIEW FOR HOW TO SAVE A CSS FILE AnD DEFInIng RULES 1. Look at your screen. In the upper right-hand corner, there should be a panel called “CSS Styles”. It looks like this: In the upper right-most corner of that panel, click and hold on this icon. And drag down to “new”. now, you should get a win- dow that looks like this:
  • 4. 2. You are adding a new CSS rule to your document. Do the following: 4 - Selector Type: select “Tag” (we’ll making Classes and IDs after). - Tag: click and hold the two arrows to the right of the field. Drag down to select “p”. You are defining the “p” (paragraph) tag. - Define in: select “(new Style Sheet File)” - click “Ok” 3. Save your styles before defining any rules. name your CSS file: “class_id_selectors_2.css” and save it in your “CSS_tutorial_2” folder. You will only have to do this once. The next time we add a rule, it will be much easier. 4. Once your “class_id_selectors_2.css” is saved, a window will automatically pop up. Save it with the following definitions (Only set the following rules for the type category. Don’t worry about the other categories yet).
  • 5. 5. now you should have a <p> defined in your style sheets window. now, highlight the text you wrote 5 in the design window. At the bottom, in the properties window, select the “format” pulldown menu at the far upper left and select “paragraph”. This makes all your text formatted with the <p> tag. Look in the code view—your html should look like this: <body> <p>This is my paragraph tag.</p> <p>This is my class selector.</p> <p>The ID selector overrides my class and paragraph selectors.</p> </body> </html> And the design view should look like this: now let’s start applying classes and IDs to this content. IV. CREATIng RULES FOR CLASSES 1. In the CSS window, underneath properties, click on the page + icon. (new CSS rule) Select “class” radial button (at the top) and name the new rule “p_class”. Make sure that the bottom radial button reads as “define in: class_id_selectors_2.css”.
  • 6. 2. In the CSS rules definition window, select OnLY the following: (right now we are only going to 6 change the weight and the color of the font.) Click ok. 3. In the design view, highlight the text that reads “This is my class selector.” In the properties window, look to the far left to the pulldown menu that reads “Format: Paragraph”. To the right of that menu is another pulldown menu that reads “Style.” In the “style” pulldown menu you should now see an op- tion to select “p_class”. Once you have selected it, see your text change to bold and a dark purple color. notice how your class selector changed the color and weight of the text, but nOT the font! This is because we didn’t change the font... it automatically picks up on the specifications of the original <p> tag you defined, unless you define it otherwise. This is the beauty of cascading style sheets! (You can always go back and change the font, border, color, etc. etc...)
  • 7. 4. Let’s take a look at what your html is doing here: 7 <body> <p>This is my paragraph tag.</p> <p class=”p_class”> This is my class selector. </p class> <p>The ID selector overrides my class and paragraph selectors.</p> </body> </html> Here’s what the html mark-up is saying: this class belongs to the <p> tag, and it’s called “p_class”. All the text in between belongs to the <p> tag, but apply the class properties to it. 5. Here’s what your CSS file should look like: @charset “UTF-8”; p { font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; color: #993300; } .p_class { font-weight: bold; color: #663366; } It makes sense, correct? notice the class definition begins with a “.” now let’s move on to IDs. V. CREATIng RULES FOR IDs 1. In the CSS window, underneath properties, click on the page + icon. (new CSS rule) Select “Ad- vanced: IDs, pseudo-class selectors” radial button (at the top) and name the new rule “#p_id”. Make sure that the bottom radial button reads as “define in: class_id_selectors_2.css”.
  • 8. 2. In the CSS rules definition window, select OnLY the following: (right now we are going to change 8 the font, case, and color.) Click ok. 3. In the design view, highlight the text that reads “This is my class selector.” Look in the properties window, to the pulldown menu “Style.” notice there is no option to select “#p_id”... This is because you can only use an ID once! Let’s write the mark-up for this, as it’s not easy to apply this change in the Dreamweaver interface. In your html mark-up, key in the following (in pink): <body> <p>This is my paragraph tag.</p> <p class=”p_class”> This is my class selector.</p class> <p id=”p_id”> The ID selector overrides my class and paragraph selectors.</p id> </body> </html> You are telling the <p> tag that this ID belongs to it, and it’s called “p_id”. All the text in between belongs to the <p> tag, but applies the ID properties to it. You can only use this once in your document. Here’s what your text looks like now:
  • 9. 4. Here’s what your CSS file should look like: 9 @charset “UTF-8”; p { font-family: Arial, Helvetica, sans-serif; font-size: 12px; font-weight: normal; color: #993300; } .p_class { font-weight: bold; color: #663366; } #p_id { font-family: Georgia, “Times New Roman”, Times, serif; text-transform: uppercase; color: #006633; } notice the following: - the ID definition begins with a “#” - the ID it doesn’t define the type size. This information from the original <p> tag. - the semi-colon (;) after each rule. next, we will move onto divs. Divs are containers. This is where things really get exciting as you are able to define “chunks” for your layout!