Тёмный

CSS Selectors: Classes and IDs 

CodeBabes
Подписаться 79 тыс.
Просмотров 144 тыс.
50% 1

codebabes.com/courses/css-vir...
Now that we have the basics, let’s talk more about selectors. Here is the syntax we showed you earlier. CSS is made up of a selector and property-value pairs.
CSS has different types of selectors. Let’s open our text editor, and browser, and look at type selectors first. Type selectors refer to HTML elements within the page. Here is the HTML generating the page, you can see the H1 and H2 headers, paragraphs, and a list. Now let’s look at the CSS. If we want to turn the first H1 tag blue we change the color to blue and refresh the page. So, type selectors select all the elements of a certain type of HTML tag, like divs, spans, headings, paragraphs. Any visible HTML element.
Sometimes you want to apply the same CSS styling to different elements, so instead of writing them all out, like this: H1, then H2, then H3, you can use what is called a multiple selector. Add a list of all the elements you want to style, separated by commas, so H1, H2, H3 and then give them all the same color.
If you want to write a comment in your CSS you can do it like this, forward slash, asterisk, your comment, asterisk, forward slash. Comments are great to remind you of what you were thinking, or to tell other people what you were thinking, kind of like Facebook... “And no, before you ask, I won’t accept your friend request.”
Type selectors are the most basic and they change all the HTML tags of a certain type. What if you want to change just one tag? That’s where classes come in. Classes are a group of CSS properties that can be applied to any tag. To use a class you have to add the class attribute to an HTML element, and then the corresponding class and styles can be added to your stylesheet. In the style sheet a class will have a period before the name to identify it as a class.
Let’s open the text editor and do an example by adding a class, highlight, to change the background color on a paragraph to yellow. Just add the class attribute to the paragraph element you want to highlight and then add the highlight class to the CSS style sheet. Now the paragraph specified will have a yellow background.
Classes can be defined differently for different tags, like paragraph dot highlight, or H1 dot highlight. Let’s add both to the style sheet and create an H1 highlight with a color property, then we can go into the HTML and add the highlight class to the H1 header. When we refresh, we see the H1 element has a different background color. You can add the class to as many HTML elements as you wish. Classes are polygamist, like Mormons, one to many.
IDs are another type of selector. They work like classes, except that, “THERE CAN ONLY BE ONE” id per page, like the Highlander. One use of IDs is for page layout. For example, if we want a div element to be the footer of the page we can add an ID of footer to this bottom div. Now lets add a width and height to the footer and a gray background in the CSS. Since we have a footer, we can wrap the rest of the HTML in a div tag with an ID of content.
Next are contextual selectors. They allow you to apply styles to tags that meet a certain criteria and are in a parent child relationship. There are various forms of child and sibling selectors. The most common, is the descendant selector. It selects all the children, grandchildren, great-grandchildren, you get the point. So, we want to style paragraphs in the footer differently from paragraphs in the content. We would use the descendant selector, or more simply, a space. It reads, pound, footer, space, paragraph. And another selector that reads pound, content, space, paragraph. Now, we can add a background color for the paragraphs in our content, and a border for the footer paragraph. background: #af295c; footer: #189fc4
Last are sudo classes. These select specific states of an element, with the addition of a colon. Most commonly these are used for links , with four possibilities: Link, Visited, Hover and Active. The four sudo classes should be used in this order so they don’t interfere with each other. Link is for things that have not been clicked, and can usually be omitted. Visited is for links that have been clicked before, Hover is what happens when your mouse hovers over the link, and Active is the link’s state while it is being clicked.
Let’s add some links to our HTML, remove the underline, and change the color.
Open up your text editor. First, let’s add two links to our HTML. One to Google, and one to Reddit. Let’s look at our HTML with these links added. You can see the links are underlined, and if they are inside a paragraph they inherit that paragraph’s color, this parent-child inheritance is a big part of CSS.
...

Опубликовано:

 

30 апр 2014

Поделиться:

Ссылка:

Скачать:

Готовим ссылку...

Добавить в:

Мой плейлист
Посмотреть позже
Комментарии : 55   
@novicesim3642
@novicesim3642 9 лет назад
Thanks for the lessons, it is so refreshing.
@tigerroar6071
@tigerroar6071 5 лет назад
I love codebabes!!
@nguyentien4711
@nguyentien4711 3 года назад
Oh thank God, these videos save my life 😆😆😆
@themajorthom5978
@themajorthom5978 3 года назад
Me and my friends found our new favourite teacher
@matiasponce7712
@matiasponce7712 10 месяцев назад
gracias por el contenido de calidad , gracias a ustedes pude desarrollar mi primera pagina web
@vishalsinghdhamiak47
@vishalsinghdhamiak47 2 года назад
This video really helps
@adorableandray
@adorableandray 7 лет назад
Thank god there is a translation in the vid info section : )
@powboy01
@powboy01 9 лет назад
i fuckin' adore u for a while i didn't think i'd study anything besides c++ yet i'm right here learning css and html
@aryansaxena4978
@aryansaxena4978 2 года назад
I wanna push my code into her repository
@notuntrue8569
@notuntrue8569 9 лет назад
4:05 when u say hover u say hower lol :P
@powboy01
@powboy01 9 лет назад
Kyle Secret she must be german...dat accent tho
@warnpassion
@warnpassion 9 лет назад
***** That's not a German accent but an eastern European, probably Armenian or Slovene.
@powboy01
@powboy01 9 лет назад
warnpassion even more sexy to me
@CamiloOrejuela
@CamiloOrejuela 9 лет назад
She is a czech.
@aminm7714
@aminm7714 5 лет назад
Her name is Veronica Lavery
@carlmorris8993
@carlmorris8993 7 лет назад
Thanks. Tedious having to individually class name multiple elements.
@Eero59
@Eero59 7 лет назад
Those brackets really tied the code together
@sexypotato4427
@sexypotato4427 6 лет назад
i don't know where to look
@IamALeaf
@IamALeaf 4 года назад
Wth this is the same girl who models in Prokos Figure Drawing course.
@nghiepnguyen4018
@nghiepnguyen4018 5 лет назад
please link music intro opening
@manojpandey-hw2gm
@manojpandey-hw2gm 8 лет назад
dear I want to use Google form as my html form can anybody help
@wildyato3737
@wildyato3737 4 года назад
Why My Id name as 'eyes' are set as Align:Right;
@thehungariantakesalook4632
@thehungariantakesalook4632 8 лет назад
Right....she got me at 2.48 completely unprepared. I still don't think I could learn any programming from her but now I really wish that she would be the one who wakes me up each morning with that smile and a kiss. That could turn any programmer's boring life into heaven....
@xamDeluxe
@xamDeluxe 9 лет назад
thx! it's a nice girl and well explained
@AspirantNoteBooks
@AspirantNoteBooks 6 лет назад
not able to focus properly
@nitinkumarupadhyay2214
@nitinkumarupadhyay2214 2 года назад
I wanna this type of teacher in my school.😂😂😂
@asadshaikh4643
@asadshaikh4643 2 года назад
Not possible bhai😔😔
@aryangurung1557
@aryangurung1557 2 года назад
@@asadshaikh4643 toh kya hua, mehenat karo aur apne baccho ko usslevel par pahuchao jidhar woh esa class join kar sake
@vishalsinghdhamiak47
@vishalsinghdhamiak47 2 года назад
Dil lae gyi kudi
@tsusec
@tsusec 8 лет назад
What does the CSS stand for? " CuteSuperSexy " ?
@avro5457
@avro5457 8 лет назад
+Matija S Cascading Style Sheets
@Interestingworld4567
@Interestingworld4567 7 лет назад
ohhhhhhhh GOD .....u look so beautiful 😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍😍🤔😍
@pmAdministrator
@pmAdministrator 7 лет назад
How easy does this make you look?
@JM-co6rf
@JM-co6rf 7 лет назад
anybody else notice the color was 69696969 ?
@RodneyAmey
@RodneyAmey 6 лет назад
J M it's a dim gray color for hexadecimal #696969
@noelpastrana5100
@noelpastrana5100 9 лет назад
yeah bigger is better.... the link bro.. the links.
@lukasvanagas6462
@lukasvanagas6462 7 лет назад
bigger is better lolllll
@sida_g567
@sida_g567 3 года назад
she is not a coder just an actress
@user-mf3tc7uz2d
@user-mf3tc7uz2d 8 лет назад
طب ما هي الدنيا حلوه والمجال جميل اوي
@AkramSaleh717
@AkramSaleh717 8 лет назад
+‫هنا فارسكور‬‎ شرحها حلو قوي
@farshad2929
@farshad2929 3 года назад
😂🤣😂🤣🤣😂😂
@treelonmusk5723
@treelonmusk5723 7 лет назад
goddess...
@chandrajitkarmakar2333
@chandrajitkarmakar2333 3 года назад
@CodeBabes ,please don't be so prominent, it causes very much distraction.
@mrigankabora4068
@mrigankabora4068 7 лет назад
whts the name of the gal
@jeianceuriarte2393
@jeianceuriarte2393 7 лет назад
Mriganka Bora veronica
@hoangvacban
@hoangvacban 2 года назад
đcm ảo thật đấy
@rphuntarchive1
@rphuntarchive1 7 лет назад
I love this series, but the audio on this video is horrendous. And she isn't the best speaker.
@TOWERcloudslba
@TOWERcloudslba 7 лет назад
I wish she wasn't speaking so low!
@hannalonac4453
@hannalonac4453 6 лет назад
what dude(s) had that stupid idea again
@technicalguruinwonderlandh5999
Very inappropriate
Далее
CSS Box Model Stripped to the Basics!
3:31
Просмотров 341 тыс.
CSS Selectors Tutorial for Beginners
20:34
Просмотров 43 тыс.
Повага | GOVOR TikTok #govor #shots
00:53
Просмотров 285 тыс.
HTML Layouts with HTML 5
2:47
Просмотров 153 тыс.
Learn Every CSS Selector In 20 Minutes
19:38
Просмотров 438 тыс.
Getting a Domain Name and Hosting for your Website
3:44
Intro to Javascript - Programming Virgin
4:15
Просмотров 273 тыс.
Intro to PHP Arrays - PHP Virgin
3:04
Просмотров 128 тыс.
HTML section elements are a lie (sort of)
7:59
Просмотров 135 тыс.
HTML Id Attribute | How to use Id Attribute in HTML
2:40
Optimizing a Page for SEO: Keywords, Linking & Content
3:48