Web Engineering CSS. By Assistant Prof Malik M Ali

Similar documents
Appendix D CSS Properties and Values

CSS Cascading Style Sheets

INTRODUCTION TO CSS. Mohammad Jawad Kadhim

Networks and Web for Health Informatics (HINF 6220) Tutorial 8 : CSS. 8 Oct 2015

IMY 110 Theme 6 Cascading Style Sheets

CSS Selectors. element selectors. .class selectors. #id selectors

Cascading Style Sheets

INTERNATIONAL UNIVERSITY OF JAPAN Public Management and Policy Analysis Program Graduate School of International Relations

HTML & CSS. SWE 432, Fall 2017 Design and Implementation of Software for the Web


COMS 359: Interactive Media

Chapter 3 Style Sheets: CSS

GIMP WEB 2.0 MENUS WEB 2.0 MENUS: HORIZONTAL NAVIGATION BAR CREATING AN HTML LIST

Introduction to Web Design CSS Reference

Introduction to Web Design CSS Reference

BIM222 Internet Programming

Cascading Style Sheets CSCI 311

3.1 Introduction. 3.2 Levels of Style Sheets. - The CSS1 specification was developed in There are three levels of style sheets

- The CSS1 specification was developed in CSS2 was released in CSS2.1 reflects browser implementations

Parashar Technologies HTML Lecture Notes-4

Module 2 (VII): CSS [Part 4]

Welcome Please sit on alternating rows. powered by lucid & no.dots.nl/student

UNIVERSITI TEKNOLOGI MALAYSIA TEST 1 SEMESTER II 2012/2013

Deccansoft Software Services

CSS3 Basics. From & CSS Visual Dictionary Learning Curve Books, LLC

Introduction to Multimedia. MMP100 Spring 2016 thiserichagan.com/mmp100

TAG STYLE SELECTORS. div Think of this as a box that contains things, such as text or images. It can also just be a

Web Design and Development Tutorial 03

Zen Garden. CSS Zen Garden

2005 WebGUI Users Conference

Introduction to using HTML to design webpages

Cascading Style Sheet Quick Reference

Web Design and Implementation

GIMP WEB 2.0 MENUS. Web 2.0 Menus: Horizontal Navigation Bar with Dynamic Background Image

- The CSS1 specification was developed in CSSs provide the means to control and change presentation of HTML documents

Website Development with HTML5, CSS and Bootstrap

Unit 20 - Client Side Customisation of Web Pages. Week 2 Lesson 4 The Box Model

Internet Programming 1 ITG 212 / A

CSS Styles Quick Reference Guide

HTML and CSS COURSE SYLLABUS

Make a Website. A complex guide to building a website through continuing the fundamentals of HTML & CSS. Created by Michael Parekh 1

ADDING CSS TO YOUR HTML DOCUMENT. A FEW CSS VALUES (colour, size and the box model)

CS197WP. Intro to Web Programming. Nicolas Scarrci - February 13, 2017

INFS 2150 Introduction to Web Development

INFS 2150 Introduction to Web Development

Page Layout. 4.1 Styling Page Sections 4.2 Introduction to Layout 4.3 Floating Elements 4.4 Sizing and Positioning

ITNP43: HTML Lecture 4

Adding CSS to your HTML

Cascade Stylesheets (CSS)

CSS. M hiwa ahamad aziz Raparin univercity. 1 Web Design: Lecturer ( m hiwa ahmad aziz)

CSC309 Programming on the Web week 3: css, rwd

CSS. Shan-Hung Wu CS, NTHU

CSS.

NAVIGATION INSTRUCTIONS

COSC 2206 Internet Tools. CSS Cascading Style Sheets

WEBSITE PROJECT 2 PURPOSE: INSTRUCTIONS: REQUIREMENTS:

Unit 20 - Client Side Customisation of Web Pages. Week 2 Lesson 4 The Box Model

COMS 359: Interactive Media

Wanted! Introduction. Step 1: Styling your poster. Activity Checklist. In this project, you ll learn how to make your own poster.

CSS مفاهیم ساختار و اصول استفاده و به کارگیری

COPYRIGHTED MATERIAL. Contents. Chapter 1: Creating Structured Documents 1

GIMP WEB 2.0 MENUS. Web 2.0 Menus: Horizontal Navigation Bar

CSS Box Model. Cascading Style Sheets

Chapter 3 CSS for Layout

ID1354 Internet Applications

Building Page Layouts

Cascading Style Sheets (CSS)

3.1 Introduction. 3.2 Levels of Style Sheets. - HTML is primarily concerned with content, rather than style. - There are three levels of style sheets

Ministry of Higher Education and Scientific Research

CSS. Selectors & Measurments. Copyright DevelopIntelligence LLC

CSS: The Basics CISC 282 September 20, 2014

CSS. Lecture 16 COMPSCI 111/111G SS 2018

Client-Side Web Technologies. CSS Part II

Client-Side Web Technologies. CSS Part I

CASCADING STYLESHEETS

CSS

CSS: Lists, Tables and the Box Model

<style type="text/css"> <!-- body {font-family: Verdana, Arial, sans-serif} ***set font family for entire Web page***

- HTML is primarily concerned with content, rather than style. - However, tags have presentation properties, for which browsers have default values

CSS Lecture 16 COMPSCI 111/111G SS 2018

AGENDA :: MULTIMEDIA TOOLS :: (1382) :: CLASS NOTES

CSS worksheet. JMC 105 Drake University

Controlling Appearance the Old Way

Introduction to WEB PROGRAMMING

CSS THE M\SS1NG MANUAL. David Sawyer McFarland. POGUE PRESS" O'REILLr Beijing Cambridge Farnham Köln Paris Sebastopol Taipei Tokyo

CSS: Cascading Style Sheets

COMP519 Web Programming Lecture 7: Cascading Style Sheets: Part 3 Handouts

CSS Cascading Style Sheets

Reading 2.2 Cascading Style Sheets

CITS3403 Agile Web Development 2019 Semester 1

APPLIED COMPUTING 1P01 Fluency with Technology

Proper_Name Final Exam December 21, 2005 CS-081/Vickery Page 1 of 4

Chapter 1 Getting Started with HTML 5 1. Chapter 2 Introduction to New Elements in HTML 5 21

READSPEAKER ENTERPRISE HIGHLIGHTING 2.5

1 of 7 11/12/2009 9:29 AM

The default style for an unordered (bulleted) list is the bullet, or dot. You can change the style to either a square or a circle as follows:

Tutorial 4: Creating Special Effects with CSS

To link to an external stylesheet, the link element is placed within the head of the html page:

COMP519 Web Programming Lecture 6: Cascading Style Sheets: Part 2 Handouts

Assignments (4) Assessment as per Schedule (2)

Transcription:

Web Engineering CSS By Assistant Prof Malik M Ali

Overview of CSS CSS : Cascading Style Sheet a style is a formatting rule. That rule can be applied to an individual tag element, to all instances of a certain tag within a document to all instances of a certain tag across a group of documents Let us define a style for an unordered list <ul style="list-style-type: square"> - inline style It will be defined for that particular element only.

Problem 1: What if we have many <ul> tags on the same page? Solution: Define style rules in your HTML page s Head i.e. use Internal Style sheet Problem 2: What if we have many <ul> tags on multiple pages? Solution: Define style rules in a separate file with the extension.css i.e. use External Style Sheet

How to define Internal Style Sheet Internal style sheets are defined inside head section of html page using <style> tag. <head> <style type= text/css > ul { list-style-type: square; } Ol { list-style-type: lower-alpha; } </style> </head>

Example

External Style Sheet

How to attach external style sheet

Defining CSS Rules A rule is made up of two parts Selector: The selector is the portion of the rule that dictates exactly how the web browser should select the elements to apply the style to. CSS includes a variety of selectors Properties

Border, Margin and Padding

Universal Selector The Universal selector indicates that the style should apply to any element in the web page Example * { } Font-family: Arial;

Type Selectors The Type selector allows you to create a style that applies to all instances of a specific type of HTML element. p{ font-family: Arial; } h1{ font-size: 14px; } h1,h2,h3 { color: red; }

Type Selectors <style> hr { color: green; background-color: green; height: 5px; width: 50%; text-align: left; } </style>

Type Selector Example

ID Selectors An ID selector is another special type of CSS selector that allows you to create styles that target elements with specific ID values. ID selectors are distinguished from other selector types by prefixing them with a hash mark (#) #title { font-size: larger; font-weight: bold; }

ID Selector Exercise Question

Class Selectors A Class selector is a special type of CSS selector that allows you to apply a style to any element with a specific class name. The class name is defined in HTML using the class attribute, which is present on almost every element. Class selectors are distinguished from other selector types by prefixing them with a single period (.).title{ font-size: larger; font-weight: bold; }

Exercise Question Copy two paragraphs of lorem ipsum text from some online text generator Paste each paragraph in a div Define common style attributes inside mydiv class Define two other classes named scheme1 and scheme2 one for each div for different style values

Descendant Selectors Descendant selectors allow you to create styles that target HTML elements that are descendants of a specific type of element. The following sample demonstrates a style that will be applied to any <span> tag that is a descendant of a <div> div span { } font-family: Arial;

Practice Example

Child Selectors The Child selector is similar to the Descendant selector except unlike the Descendant selector, which searches the entire descendant hierarchy of an element, the Child selector restricts its element search to only those elements that are direct children of the parent element. div > span { } font-family:arial;

Attribute Selectors Attribute selectors enable you to define a style that is applied to elements based on the existence of element attributes rather than the actual element name. input[type=text] { width: 150px; display: block; margin-bottom: 10px; background-color: yellow; } input[type=button] { width: 120px; margin-left: 35px; display: block; }

Adjacent Selectors Adjacent selectors enable you to select HTML elements that are immediately adjacent to another element type. For example, in an unordered list, you might want to highlight the first list item and then have all the following items use a different style li { color: maroon; } li+li { color: silver; }

Pseudo-Classes Those classes having some kind of intelligence First-Child Pseudo-Class: The first-child pseudo-class allows you to indicate that the rule should select the first child element M of an element N. Example: #title p:first-child { font-size: xx-small; }

Pseudo-classes Example Apply previously defined First-Child pseudo class to the following HTML code <div id="title"> Bahria University <p>management Sciences</p> <p>computer Science</p> This text is outside the paragraph tag </div>

Pseudo Classes related to anchor tags

Practice Exercise

Paragraph Formatting Text-indent: Indents only the first line of the paragraph. Example: p { text-indent: 20px} Padding: adds specific amount of space between the border of an element and its contents. Applies equally to all lines of text in a paragraph. Example: p { padding: 20px }, padding-left, right, top and bottom Margin: This adds a specified amount of white space around an element, on the outside of the element. It applies equally to all lines of text in the paragraph. Example: p { margin: 20px }

Paragraph formatting text-indent n px, padding: n px, margin: n px (top px, right px, bottom px, left px) text-align: left/right/center/justify line-height: n px /150% etc, word-spacing: npx, letter-spacing: npx font-size, font-family, background, color font-weight: bold/normal font-style: italic/normal text-decoration: underline / line-through / blink / none

Paragraph Formatting Borders border: size px color style; e.g. border: 20px red solid; border-style, border-top-style, border-bottomstyle border-color, border-top-color, border-bottomcolor, border-width: n px Border Styles: Solid, Dotted, Dashed, Double, Groove, ridge, inset, outset, none

Practice Question Fix following style properties Border-top-style Border-bottom-style Padding-top Padding-bottom

Div and Table Formatting Common style attributes of Div and Span Top, left, bottom, right, width, height, overflow, float, border, position Values for overflow: visible, hidden, scroll, auto Values for float: left, right, top, bottom Common style attributes of Tables Width, height, padding, margin, color, background-color, border-collapse: collapse, border: 5px solid red,

Practice Exercise Generate the following output using div type selector

Output of Exercise Question Common style attributes: Width, height, padding, float, border, text-align Uncommon style attributes: Color, background-color, font-family

Positioning CSS Elements The position property specifies the type of positioning method used for an element.there are four different position values: static relative fixed absolute Elements are then positioned using the top, bottom, left, and right properties. However, these properties will not work unless the position property is set first. They also work differently depending on the position value.

Static Positioning Static positioned elements are not affected by the top, bottom, left, and right properties. An element with position static is not positioned in any special way; it is always positioned according to the normal flow of the page divstatic { position: static; border: 3px solid black; }

Relative Positioning Setting the top, right, bottom, and left properties of a relatively-positioned element will cause it to be adjusted away from its normal position. Other content will not be adjusted to fit into any gap left by the element. divrelative { position: relative; left: 30px; border: 3px solid black; }

Relative Positioning

Position Fixed it always stays in the same place even if the page is scrolled. The top, right, bottom, and left properties are used to position the element. A fixed element does not leave a gap in the page where it would normally have been located. divfixed { position: fixed; bottom: 0; right: 0; width: 300px; border: 3px solid blue; }

Position Absolute An element with position: absolute; is positioned relative to the nearest positioned ancestor. However; if an absolute positioned element has no positioned ancestors, it uses the document body, and moves along with page scrolling.

divabsolute { position: absolute; top: 80px; right: 0; width: 200px; height: 100px; border: 3px solid Black; } Position Absolute

Position Absolute

How to define External Style Sheet Step I: Press ctrl + n in your visual studio environment. You will see Add New Item dialog box. Alternatively right click project name in solution explorer and then click Add menu item and then click Add new item Step II: Select style sheet item, set name for this file and press Add button. Step III: Add reference of this style sheet to your HTML page in head section as shown below <link href= mystyle.css type= text/css rel= stylesheet />

Exercise Question

Instructions for Exercise 03 The background of each fieldset is lightyellow The border of each fieldset is yellow, with 10px width e.g. border:10px solid yellow The fieldset needs to have margin-bottom:10px The width of each fieldset is 720px The width of each label is 180px The label text needs to have display:inline-block The label text needs to be right-align and top-align The labels of the checkbox and the radio needs to have width:auto For the words on both sides of the two range, you can use any appropriate style e.g. text-align:center The textarea needs to be width:360px and height:50px

Inline styling is not allowed Style rules are added so that the label and input elements become significantly larger when the mouse is moved over them (and return to normal size when the mouse moves away from them). Add following code to your html. It will show picture in the image box

Javascript code for viewing picture window.onload = function() { var files = document.queryselectorall("input[type=file]"); files[0].addeventlistener("change", function(e) { if(this.files && this.files[0]) { var reader = new FileReader(); reader.onload = function(e) { document.getelementbyid("preview").setattribute( "src", e.target.result); } reader.readasdataurl(this.files[0]); } }); }

Navigation Bar Build two separate navigation bars as shown