การจัดรูปแบบเว็บด้วย CSS การเขียนโปรแกรมเว็บ. Selectors & cascading PatternMeaning *Universal selector: matches any element. EType selector: matches any.

Slides:



Advertisements
Similar presentations
1 Cascading Style Sheets Continued Different kinds of selectors in a style sheet –Simple- Pseudo-Class –Contextual- Pseudo-Element –Class Image Styles.
Advertisements

Today CSS HTML A project.
Tutorial 6 Creating a Web Form
CIS 1310 – HTML & CSS 6 Layout. CIS 1310 – HTML & CSS Learning Outcomes  Describe & Apply the CSS Box Model  Configure Float with CSS  Designate Positioning.
Cascading style sheets CSS
Tutorial 3 Introducing Cascading Style Sheets. XP New Perspectives on Blended HTML, XHTML, and CSS2 Objectives Learn about Cascading Style Sheets Write.
XP 1 Creating Web Page Forms Designing a Product Registration Form Tutorial 6.
Using Cascading Style Sheets CSS Basics. Goals Understand basic syntax of Cascading Style Sheets (CSS) Understand basic syntax of Cascading Style Sheets.
Creating Web Page Forms. Objectives Describe how Web forms can interact with a server-based program Insert a form into a Web page Create and format a.
Tutorial 6 Working with Web Forms
XP Tutorial 6: Creating Web Page Forms. XP An Example of a Form.
XP 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
Tutorial 4 Creating Special Effects with CSS
Tutorial 6 Working with Web Forms. XP Objectives Explore how Web forms interact with Web servers Create form elements Create field sets and legends Create.
Working with Cascading Style Sheets. 2 Objectives Introducing Cascading Style Sheets Using Inline Styles Using Embedded Styles Using an External Style.
Creating Web Page Forms
Web Development & Design Foundations with XHTML Chapter 9 Key Concepts.
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
1 Web Developer & Design Foundations with XHTML Chapter 6 Key Concepts.
XP Tutorial 6New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Creating Web Page Forms Designing a Product Registration Form Tutorial.
XP Tutorial 6New Perspectives on HTML and XHTML, Comprehensive 1 Creating Web Page Forms Designing a Product Registration Form Tutorial 6.
1 Creating Web Forms in HTML Web forms collect information from customers Web forms include different control elements including: –Input boxes –Selection.
Forms and Form Controls Chapter What is a Form?
Working with Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of a document.
Using Cascading Style Sheets. Introduction to Styles and Properties  Cascading Style Sheets (CSS) are a standard set by the World Wide Web Consortium.
XP Tutorial 7New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks.
Tutorial 4 Creating Special Effects with CSS. XP Objectives Work with CSS selectors Create styles for lists Create and apply class styles Create a rollover.
XHTML Introductory1 Forms Chapter 7. XHTML Introductory2 Objectives In this chapter, you will: Study elements Learn about input fields Use the element.
Tutorial 4 Creating Special Effects with CSS
CSS Positioning Creating Special Effects with CSS CS202 Working with Cascading Style Sheets (Chapter 4) CS202 1.
1 Working with Cascading Style Sheet (CSS) (contd.)  What we will cover… 1. Color (decimal and hexadecimal representation) 2. Floating elements 3. Styling.
 2008 Pearson Education, Inc. All rights reserved Introduction to XHTML.
Tutorial 7 Creating Forms. Objectives Session 7.1 – Create an HTML form – Insert fields for text – Add labels for form elements – Create radio buttons.
 2008 Pearson Education, Inc. All rights reserved Introduction to XHTML.
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Tutorial 7.
1 HTML Forms
ITCS373: Internet Technology Lecture 5: More HTML.
Advanced Cascading Style Sheets (CSS) Lecture # July 2013.
Tutorial 6 Working with Web Forms. XP Objectives Explore how Web forms interact with Web servers Create form elements Create field sets and legends Create.
Tutorial 6 Working with Web Forms. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore how Web forms interact with.
Creating Web Page Forms. Introducing Web Forms Web forms collect information from users Web forms include different control elements including: –Input.
1 HTML Forms
XP 1 Tutorial 6 Creating Web Page Forms. XP 2 Tutorial Objectives  Describe how Web forms can interact with a server-based program  Review the various.
Forms Collecting Data CSS Class 5. Forms Create a form Add text box Add labels Add check boxes and radio buttons Build a drop-down list Group drop-down.
XP Review 2 New Perspectives on JavaScript, Comprehensive1 Introducing Cascading Style Sheets Formatting Web Pages with CSS.
Positioning and Printing Creating Special Effects with CSS.
CNIT 132 – Week 4 Cascading Style Sheets. Introducing Cascading Style Sheets Style sheets are files or forms that describe the layout and appearance of.
©SoftMooreSlide 1 Introduction to HTML: Forms ©SoftMooreSlide 2 Forms Forms provide a simple mechanism for collecting user data and submitting it to.
Tutorial 6 Working with Web Forms. 2New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition Objectives Explore how Web forms interact with.
Tutorial 4 Creating Special Effects with CSS. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Work with CSS selectors.
Tutorial 4 Creating Special Effects with CSS. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Work with CSS selectors.
Creating Web Page Forms COE 201- Computer Proficiency.
HTML Forms.
Tutorial 4 Creating Special Effects with CSS. XP Objectives Work with CSS selectors Create styles for lists Create and apply class styles Create a rollover.
HTML Forms. A form is simply an area that can contain form fields. Form fields are objects that allow the visitor to enter information - for example text.
Copyright (c) 2004 Prentice-Hall. All rights reserved. 1 Committed to Shaping the Next Generation of IT Experts. Project 6: Creating XHTML Forms Kelly.
1 HTML forms (cont.)
Internet & World Wide Web How to Program, 5/e Copyright © Pearson, Inc All Rights Reserved.
Tutorial 3 Designing a Web Page with CSS
Tutorial 6 Creating a Web Form
XP Tutorial 7New Perspectives on HTML and XHTML, Comprehensive 1 Working with Cascading Style Sheets Creating a Style for Online Scrapbooks Tutorial 7.
XP Tutorial 6New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Creating Web Page Forms Designing a Product Registration Form Tutorial 6.
HTML5 and CSS3 Illustrated Unit E: Inserting and Working with Links.
2440: 141 Web Site Administration Web Forms Instructor: Joseph Nattey.
Tutorial 6 Working with Web Forms
ITE 115 Creating Web Page Forms
CNIT 131 HTML5 - Forms.
Tutorial 4 Creating Special Effects with CSS
Chapter 6: Creating Web Page Forms. An Example of a Form.
Presentation transcript:

การจัดรูปแบบเว็บด้วย CSS การเขียนโปรแกรมเว็บ

Selectors & cascading PatternMeaning *Universal selector: matches any element. EType selector: matches any E element (i.e., an element of type E; e.g. H1 or P). E FDescendant selector: matches any F element that is a descendant of an E element. E > FChild selector: matches any F element that is a child of an element E. E + FAdjacent siblings selector: Matches any F element immediately preceded by an element E. E[foo]Attribute selector: matches any E element with the "foo" attribute set (whatever the value). E[foo="warning"]Attribute selector: matches any E element whose "foo" attribute value is exactly equal to "warning". E[foo~="warning"] Attribute selector: matches any E element whose "foo" attribute value is a list of space-separated values, one of which is exactly equal to "warning". E[lang|="en"] Attribute selector: matches any E element whose "lang" attribute has a hyphen-separated list of values beginning (from the left) with "en“ (e.g. en-US). DIV.warningHTML only. The same as DIV[class~="warning"]. E#myidID selector: matches any E element ID equal to "myid". E:lang(c) Pseudo-class selector: matches element of type E if it is in (human) language c (the document language specifies how language is determined). E:first-childPseudo-class selector: matches element E when E is the first child of its parent. E:link, E:visited Pseudo-class selector: matches element E if E is the source anchor of a hyperlink of which the target is not yet visited (:link) or already visited (:visited). E:active, E:hover, E:focusDynamic Pseudo-class selector: matches E during certain user actions. E:first-line, E:first-letterPseudo-element selector: matches the first formatted line or letter of element E. Works in most browsers (incl. IE)

Measurement Values UnitDescription %percentage ininch cmcentimeter mmmillimeter em 1em is equal to the current font size. 2em means 2 times the size of the current font. E.g., if an element is displayed with a font of 12 pt, then '2em' is 24 pt. The 'em' is a very useful unit in CSS, since it can adapt automatically to the font that the reader uses ex one ex is the x-height of a font (x-height is usually about half the font-size) ptpoint (1 pt is the same as 1/72 inch) pcpica (1 pc is the same as 12 points) pxpixels (a dot on the computer screen)

Working with Selector Patterns  On a Web page, elements are nested within other elements, forming a hierarchical tree structure New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 4

Working with Selector Patterns  To take advantage of this tree structure, CSS allows you to create contextual selectors that express the location of an element within the hierarchy of elements parent descendant {styles} li b {color: blue} li b, h2 {color: blue} #notes b {color: blue} * {color: blue} p > b {color: blue} New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 5

Working with Selector Patterns  On occasion you might also need to select elements based on their attribute values element[att] {styles} a[href] {color: blue} New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 6

Using Selector Patterns  To apply a style to all elements in the document, use the * selector  To apply a style to a single element, use the e selector, where e is the name of the element  To apply a selector to a descendant element, f, use the e f selector, where e is the name of the parent element and f is an element nested within the parent  To apply a selector to a child element, f, use the e > f selector, where e is the name of a parent element and f is an element that is a direct child of the parent  To apply a selector to a sibling element, use the e + f selector, where e and f are siblings and f immediately follows e in the document tree New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 7

Applying Styles to Lists  To specify the list marker displayed by the browser, you can apply the style list-style-type: type New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 8

Applying Styles to Lists New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 9

Applying Styles to Lists  Most browsers place the list marker to the left of the block, lining up the markers with each list item list-style-position: position New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 10

Working with Classes  The class attribute is used when you want to identify elements that share a common characteristic...  You can use the class attribute to assign the same style to multiple elements sharing the same class value.class {styles} New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 11

Using Pseudo-Classes and Pseudo-Elements  A pseudo-class is a classification of an element based on its current status, position, or use in the document selector:pseudo-class {styles} New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 12

Using Pseudo-Classes and Pseudo-Elements New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 13

Using Pseudo-Classes and Pseudo-Elements  Pseudo-elements are abstracted from what we know of an element’s content, use, or position in the document selector:pseudo-element {styles} New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 14

Positioning Objects with CSS New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 15

Positioning Objects with CSS  Create div containers for each note  Add a class attribute to apply a common set of styles  Each note should have a unique id New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 16

Positioning Objects with CSS  CSS-P (CSS-Positioning) became part of the specification for CSS2, and positioning styles were some of the first CSS2 styles to be adopted by browsers position: type; top: value; right: value; bottom: value; left: value;  Absolute positioning enables you to place an element at specific coordinates either on a page or within a containing element position: absolute; left: 100px; top: 50px New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 17

Positioning Objects with CSS  Relative positioning is used to move an element relative to its default position on the page position: relative; left: 100px; top: 50px  You can fix an element at a specific spot in the document window while the rest of the page scrolls by setting the value of the position style to fixed  You can assign the inherit position style to an element so that it inherits the position value of its parent element New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 18

Positioning Objects with CSS New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 19

Working with Overflow and Clipping  If you want to force an element into a specified height and width, you have to define how the browser should handle a situation where content overflows the space allotted to the object overflow: type New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 20

การสร้างฟอร์มด้วย HTML การเขียนโปรแกรมเว็บ

Creating a Web Form Forms are created using the form element, structured as follows: elements  Where attributes are the attributes that control how the form is processed and elements are elements places within the form. New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 22

Creating a Web Form Form attributes usually tell the browser the location of the server-based program to be applied to the form’s data. Always specify an id or name for the form. Two attributes are available to identify the form: id and name. New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 23

Creating a Web Form The syntax of the id and name attributes are as follows: …  Where name is the name of the form and id is the id of the form. New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 24

Creating a Field Set  HTML and XHTML allow you to organize option buttons into a group of fields called field sets. controls where id identifies the field set and controls are the control elements associated with fields within the field set New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 25

Creating a Field Set  To add a caption to a field set, add the following tag after the opening tag: text Where text is the text of the field set caption. New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 26

Creating Input Boxes  The general syntax of input elements is as follows: Where type specifies the type of input control, and the name and id attributes provide the control’s name and id. New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 27

Creating Input Boxes New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 28

Working with Field Labels  You can also expressly link a label with an associated text element for scripting purposes.  The syntax for creating a form label is as follows: label text Where id is the value of the id attribute for a field’s control element, and label text is the text of the label. New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 29

Setting the Width of an Input Box  To change the width of an input box, use the width attribute, which is displayed as follows: #id{width: value} Where id is the id of the control and value is the width you want to apply to the input box New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 30

Setting the Width of an Input Box New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 31

Creating Option Buttons  Option buttons, or radio buttons allow users to make selections.  Unlike selection lists, option buttons only allow the user to select one option at a time. New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 32

Creating a Group of Option Buttons  To create a group of option buttons associated with a single field, add the elements: to the Web form, where name identifies the field associated with the collection of option buttons; id1, id2, id3, etc. identify the specific options; and value1, value2, value3, etc. are the field values associated with each option.  To specify the default option, add the following attribute to the tag: checked="checked" New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 33

Creating a Selection List  A selection list is a list box from which a user selects a particular field value or set of field values.  Selection lists are useful when there are a fixed set of possible responses from the user.  You can create a selection list using the element.  You can specify each individual selection item using the element. New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 34

Setting the Selection List Size  You can change the number of options displayed in the selection list by modifying the size attribute. The syntax is as follows: … Where value is the number of items that the selection list displays in the form. New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 35

Setting the Selection List Size New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 36

Making Multiple Selections  Add the multiple attribute to the select element to create multiple selections: … New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 37

Working with Check Boxes  To create a check box, use:  Where the name and id attributes identify the check box controls and the value attribute specifies the value sent to the server if the check box is selected.  To specify that a check box be selected by default, use the checked attribute as follows: New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 38

Specifying the Tab Order  Users typically navigate through a form with the tab key.  You can specify an alternate tab order by adding the tabindex attribute to any control element in your form.  The syntax is as follows: This syntax assigns the tab index number “1” to the fname field from the registration form. New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 39

Working with Text Area Control  Text area boxes allow users to enter comments.  An input box would be too small to accommodate the length of text for this use. New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 40

Working with Text Area Control  To create a text area box, use the textarea element:... Where the rows and cols attributes define the dimensions of the input box and the rows attribute indicates the number of lines in the input box. New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 41

Working with Text Area Control New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 42

Working with Text Area Control New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 43

Working with Form Buttons  Buttons are a type of control element that performs an action.  Types of buttons:  Command button  Submit button  Reset button New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 44

Creating a Command button  Command buttons are created using the tag:  Submit buttons submit forms to the server for processing when clicked. Syntax is as follows:  Reset buttons reset forms to their original (default) values. Syntax is as follows: New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 45

Completed Form New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 46

Designing a Custom Button  Use the button element for greater artistic control over the appearance of a button. content Where the name and value attributes specify the name of the button and the value sent to a server-based program, the id attribute specifies the button’s id, the type attribute specifies the button type, and the content is page content displayed within the button. New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 47

Creating File Buttons  File buttons are used to select files so that their contents can be submitted for processing to a program. New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 48

Working with Hidden Fields  Hidden fields are added to a form, but not displayed in the Web page. The syntax is as follows: New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 49

Working with Form Attributes  After adding the elements to your form, you’ll need to specify where to send the form data and how to send it. Use the following attributes: … Where url specifies the filename and location of the program that processes the form and the method attribute specifies how your Web browser sends data to the server. The enctype attribute specifies the format of the data stored in the form’s field. New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 50

Working with Form Attributes  The method attribute can have one of two values:  Post  Get  The get method is the default; get appends the form data to the end of the URL specified in the action attribute.  The post method sends form data in a separate data stream, allowing the Web server to receive the data through “standard input.” New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 51

Using the mailto Action  The mailto action accesses the user’s own program and uses it to mail form information to a specified address.  Bypasses the need for server-based programs.  The syntax is as follows: <form action-mailto: method=“post” enctype=“text/plain”> …  Where _address is the address of the recipient in the form. New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 52

Tips for Creating Effective Forms  Mark fields that are required, but also limit the number of unrequired fields. Don’t overwhelm your users with requests for information that is not really essential. Keep your forms short and to the point.  If you need to collect a lot of information, break the form into manageable sections spread out over several pages. Allow users to easily move backward and forward through the forms without losing data. New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 53

Tips for Creating Effective Forms  Provide detailed instructions about what users are expected to do. Don’t assume that your form is self-explanatory.  If you ask for personal data and financial information, provide clear assurances that the data will be secure. If possible, provide a link to a Web page describing your security practices.  Clearly indicate what users will receive once the form is submitted, and provide feedback on the Web site and through that tells them when their data has been successfully submitted. New Perspectives on HTML, XHTML, and Dynamic HTML, 4e 54