Internet Programming - 02
Internet Programming - 02
▪ The value attribute sets the initial value displayed in the form.
▪ The spinner control includes only the valid numbers. If the user attempts to enter an invalid
value by typing in the text field, a callout pointing to the number input element will instruct the
user to enter a valid value.
range input type
▪ The range input type appears as a slider control.
▪ You can set the minimum and maximum and specify a value.
▪ The slider appears at the value in the range when the HTML5 document is rendered.
▪ The range input type is inherently self-validating when it’s rendered by the browser as a slider
control, because the user is unable to move the slider outside the bounds of the minimum or
maximum value.
input Type tel
▪ The tel input type enables the user to enter a telephone number.
▪ The length and format of telephone numbers varies greatly based on location, making
validation quite complex. HTML5 does not self validate the tel input type.
▪ To ensure that the user enters a phone number in a proper format, you can use the pattern
attribute.
▪ When the user enters a phone number in the wrong format, a callout requesting the proper
format appears, pointing to the tel input element.
input Type
▪ The time input type enables the user to enter an hour, minute, second and fraction of a
second.
▪ The url input type enables the user to enter a URL. The element is rendered as a text field. If
the user enters an improperly formatted URL, it will not validate. HTML5 does not ensure that
the URL entered actually exists.
▪ The week input type (p. 119) enables the user to select a year and week number in the format
yyyy-Wnn.
▪ The autocomplete attribute can be used on input types to automatically fill in the user's
information based on previous input. You can enable autocomplete for an entire form or just
for specific elements.
▪ The datalist element provides input options for a text input element. The browser can use
these options to display autocomplete options to the user.
Cascading Style Sheets (CSS)
▪ Cascading Style Sheets (CSS) allows document authors to
specify the presentation of elements on a web page (e.g.,
fonts, spacing, colors) separately from the structure of the
document (section headers, body text, links, etc.)
▪ The separation of structure from presentation simplifies
maintaining and modifying a web page.
CSS Validation Service
▪ The W3C provides a CSS code validator
▪ https://jigsaw.w3.org/css-validator/
▪ It is a good idea to validate all CSS
code with this tool to make sure that
your code is correct and works on as
many browsers as possible
CSS Rules
▪ The property name is followed by a colon (:) and the value of the property.
▪ Multiple properties are separated by semicolons (;)
Inline Styles
▪ Inline styles declare an individual element’s format using the HTML attribute style.
▪ Inline styles override any other styles.
▪ Inline styles do not truly separate presentation from content.
Inline Styles (cont.)
Embedded Style Sheets
▪ Embedded style sheets embed an entire CSS document in an HTML document’s head section.
▪ Styles placed in the head apply to matching elements wherever they appear in the entire document.
▪ Style classes define styles that can be applied to any element.
Embedded Style Sheets (cont.)
Embedded Style Sheets (cont.)
font-family Property
▪ The font-family property specifies the name of the font to use.
▪ Not all users have the same fonts installed on their computers, so CSS allows you to specify a
comma separated list of fonts to use for a particular style.
▪ The browser attempts to use the fonts in the order they appear in the list. It’s advisable to end
a font list with a generic font family name in case the other fonts are not installed on the user’s
computer.
font-size Property
▪ The font-size property specifies a 12-point font. Other possible measurements in addition to pt
(point) are Relative values.
▪ Relative values— xxsmall, x-small, small, smaller, medium, large, larger, x-large and xx-large.
▪ Generally, relative values for font-size are preferred over point sizes because an author does
not know the specific measurements of the display for each client.
▪ Relative font-size values permit more flexible viewing of web pages.
▪ For example, a user may wish to view a web page on a handheld device with a small screen.
Specifying an 18-point font size in a style sheet will prevent such a user from seeing more than
one or two characters at a time. However, if a relative font size is specified, such as large or
larger, the actual size is determined by the browser that displays the font.
▪ Using relative sizes also makes pages more accessible to users with disabilities.
Conflicting Styles
▪ Styles may be defined by a user, an author or a user agent (e.g., a web browser).
▪ Styles “cascade,” or flow together, such that the ultimate appearance of elements on a page
results from combining styles defined in several ways.
▪ Most styles defined for parent elements are also inherited by child (nested) elements. The
child’s styles take precedence.
Author
User
User
Agent
Conflicting Styles (cont.)
Conflicting Styles (cont.)
External Style Sheets
▪ Style sheets are a convenient way to create a document with a uniform theme.
Positioning Elements
▪ Before CSS, controlling the positioning of
elements in an HTML document was difficult:
the browser determined positioning.
▪ Normally, elements are positioned on the page
in the order that they appear in the
▪ CSS introduced the position property and a
capability called absolute positioning.
▪ Specifying an element’s position as absolute
removes the element from the normal flow of
elements on the page.
Positioning Elements (cont.)
Positioning Elements (cont.)
▪ z-index property used to layer overlapping
elements properly.
▪ Elements that have higher z-index values are
displayed in front of elements with lower z-
index values.
▪ Relative positioning, in which elements are
positioned relative to other elements
Box Model
▪ Box Model: virtual box drawn around the block-level HTML elements.
▪ When the browser renders elements using the box model, the content of each element is
surrounded by padding, a border and a margin.
▪ CSS controls the border-width, border-color and border-style.
BOX Model (cont.)
▪ The margin property sets the space between the outside of the border and all other content on
the page.
▪ The padding property determines the distance between the content inside an element and the
inside of the element’s border.
Media Types
▪ CSS media types allow a programmer to decide what a page should look like
depending on the kind of media being used to display the page.
▪ The media type for a web page
▪ Screen : standard computer screen
▪ Handheld : designed for mobile Internet devices
▪ Braille : for machines that can read or print web pages in braille
▪ Aural : give a speech-synthesizing web browser more information about the content of the
web page. This allows the browser to present a web page in a sensible manner to a visually
impaired person.
▪ Print : affects a web page’s appearance when it is printed.
Media Types (cont.)
User Style Sheets
▪ Users can define their own user style sheets to format
pages based on their preferences.
▪ Absolute font size measurements override user style
sheets, while relative font sizes will yield to a user-
defined style.
▪ User style sheets are set in the browser’s options; not
linked to a document.
JavaScript
Client side scripting
JavaScript
▪ client-side scripting language for web-based applications that enhance the functionality and
appearance of web pages.
▪ JavaScript makes web pages more dynamic and interactive.
▪ All web browsers contain JavaScript interpreters, which process the commands written in
JavaScript.
▪ The JavaScript code can appear in the <head> section. The browser interprets the contents of
the <head> section first, so the JavaScript programs execute before the <body> of the HTML
document displays.
▪ inline scripting : JavaScript code is written in the <body> of an HTML document
JavaScript (cont.)
▪ <script type = "text/javascript">
<!--
script code here
// -->
▪ </script>
Escape sequences
User Input
Arithmetic Operator
Rules of operator precedence
▪ Multiplication, division and remainder operations are applied first. If an
expression contains several multiplication, division and remainder operations,
operators are applied from left to right.
▪ Multiplication, division and remainder operations are said to have the same
level of precedence.
▪ Addition and subtraction operations are applied next. If an expression contains
several addition and subtraction operations, operators are applied from left to
right.
▪ Addition and subtraction operations have the same level of precedence.
Equality and relational operators
Thank You