1 / 11

CS134 Web Design & Development

CS134 Web Design & Development. Understanding URL & Learn How to Use Different CSS Selector Type Mehmud Abliz. Understanding URL. When we have html code like following: <img src=“SOME URL“ /> <a href=“SOME URL"> </a>

demont
Download Presentation

CS134 Web Design & Development

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CS134 Web Design & Development Understanding URL & Learn How to Use Different CSS Selector Type Mehmud Abliz

  2. Understanding URL • When we have html code like following:<img src=“SOME URL“ /><a href=“SOME URL"> </a> • Or CSS code like:background: url(../img/pdf.png) no-repeat;list-style: url(./img/bullet2.png) inside; • We need to specify the URL. • How do we know the URL of an object (a file, or a link)?

  3. Understanding URL • Assume we have following folders and files

  4. Understanding URL • If we want to insert "image1.jpg“ in the "assign2.html" file, then the html code will be:<img src="../images/image1.jpg" />

  5. Understanding URL • Practice: • download the "c8_e1.zip“ file from the following address:http://www.cs.pitt.edu/~mehmud/cs134-2084/files/c8_e1.zip • 1) Insert "image2.jpg" in "about.html" file;2) Insert "image3.jpg" in "index.html" and also in "assign1.html";3) Make a link to "about.html", "assign1.html", "assign2.html" files in the "index.html" file.

  6. Using Different CSS Selectors • Type Selector • redefines the look of a specific tag • A type selector matches every instance of the element type in the document tree E.g. body {background-color: #000000;} • Class Selector • can apply to any tag E.g..indent{margin-right:5%;margin-left: 5%;} In HTML, <p class=“indent”> • ID Selector E.g.#myId {color: #38608A;} In HTML, <h1 id="myId">some text..</h1>

  7. Using Different CSS Selectors • Grouping • When several selectors share the same declarations, they may be grouped into a comma-separated list.e.g.h1, h2, h3 {font-family: Georgia;} • Universal selector • The universal selector, written "*", matches the name of any element type. • e.g.* {border: 2px;}

  8. Using Different CSS Selectors • Descendant selector • Sometimes, you want selectors to match an element that is the descendant of another element in the document tree(e.g., "Match those EM elements that are contained by an H1 element"). • Descendant selectors express such a relationship in a pattern. • A descendant selector is made up of two or more selectors separated by whitespace. e.g.h1 em {color: blue;}

  9. Using Different CSS Selectors • When to use which? • Use “type selector” when you want to apply certain style for all occurrences of a certain tag • Use “ID selector” if you want to apply the style for only one occurrence of a certain tag • Use “class selector” if you want to apply the style for many (but not all) occurrences of a certain tag; OR if you want to apply the style for more than one type of tags

  10. Using Different CSS Selectors • When to use which? (cont.) • Use “Grouping” When several selectors share the same declarations • Use “Universal selector” if you want all the tags in your web documents have some common style (for example, all tags don’t have any margin) • Use “Descendant selectors” if you want selectors to match an element that is the descendant of another element

  11. Using Different CSS Selectors • Practice • Save the HTML file at the following address to your local hard drive:http://www.cs.pitt.edu/~mehmud/cs134-2084/exercise/orion.html • Add following CSS rules into orion.html as internal stylesheet:*, h1, h2, h6, h1, h2, h6, p, .yellowBG, #topcontent, ul li a, #selectedli • I explain how you should add them

More Related