![]() ![]() In the above example, we use "p#alert" as the selector, which tells the browser that the following style applies to the paragraph with id "alert". Note that specifying the element type in CSS is optional when the element has an id. For example, here's how we could make our alert paragraph appear in a big yellow box with a black border and big black text: To add style to an element with an id, you preface the id with a # symbol in your CSS. Important! All classes are cancelled today. You could add id="alert" to that paragraph, like this: You want it to stand out so people are sure to notice it. You don't want it to look like all the other paragraphs on the page. For example, let's say you have a paragraph that serves as an alert on a page. We want to be able to stylize specific elements using CSS. In this unit, we're just interested in the first reason to add an ID. You'll learn more about that in the module on Javascript. You want to be able to directly access that element using Javascript.In fact, you already added id="main" to one of the div elements on your portfolio page when you created a "skip to main content" link in the lesson on Special Types of Links. You want to be able to link to a particular element within a web page.You want to stylize that element differently than other elements of the same type.You assign an id attribute to an HTML element when: ![]() For example, a that's used to markup a navigation menu might have id="navigation" or id="menu" It's a good practice to assign labels that describe the function of the element. This can be any text you like, but it has to be unique (only one item can have this label). In HTML, every element on your web page can be assigned a unique id attribute. you will have added ID and Class attributes to certain elements within a web page.you will be able to identify how Class attributes are used in CSS to enable styling of groups of elements.you will be able to identify how ID attributes are used in CSS to enable styling of individual elements.In this lesson you will learn how ID and Class attributes can be used to stylize individual elements ( id) or groups of elements ( class). ![]() What if you want to stylize some div elements one way, and other div elements a different way? That's where id and class come in. For example, when you added style to the div element that affected all div elements equally. So far you have added style to various elements in your portfolio page, but the styles you've added have affected all elements of a particular type. UNIT 3 > MODULE 5 Lesson 1: Understanding ID and Class in CSS Overview ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |