HTML Forms: Input Elements
HTML Forms: Input Elements
HTML forms are used to pass data to a server. A form can contain input elements like text fields, checkboxes, radio-buttons, submit buttons and more. A form can also contain select lists, textarea, fieldset, legend, and label elements. The <form> tag is used to create an HTML form: <form> . input elements . </form>
Text Fields
<input type="text" /> defines a one-line input field that a user can enter text into: <form> First name: <input type="text" name="firstname" /><br /> Last name: <input type="text" name="lastname" /> </form> How the HTML code above looks in a browser:
Top of Form
Note: The form itself is not visible. Also note that the default width of a text field is 20 characters.
Password Field
<input type="password" /> defines a password field:
<form> Password: <input type="password" name="pwd" /> </form> How the HTML code above looks in a browser:
Top of Form
Password:
Bottom of Form
Note: The characters in a password field are masked (shown as asterisks or circles).
Radio Buttons
<input type="radio" /> defines a radio button. Radio buttons let a user select ONLY ONE of a limited number of choices: <form> <input type="radio" name="sex" value="male" /> Male<br /> <input type="radio" name="sex" value="female" /> Female </form> How the HTML code above looks in a browser:
Top of Form
Male Female
Bottom of Form
Checkboxes
<input type="checkbox" /> defines a checkbox. Checkboxes let a user select ONE or MORE options of a limited number of choices. <form> <input type="checkbox" name="vehicle" value="Bike" /> I have a bike<br /> <input type="checkbox" name="vehicle" value="Car" /> I have a car </form> How the HTML code above looks in a browser:
Top of Form
Submit Button
2
<input type="submit" /> defines a submit button. A submit button is used to send form data to a server. The data is sent to the page specified in the form's action attribute. The file defined in the action attribute usually does something with the received input: <form name="input" action="html_form_action.asp" method="get"> Username: <input type="text" name="user" /> <input type="submit" value="Submit" /> </form> How the HTML code above looks in a browser:
Top of Form
Username:
Bottom of Form
If you type some characters in the text field above, and click the "Submit" button, the browser will send your input to a page called "html_form_action.asp". The page will show you the received input.
What is CSS?
CSS stands for Cascading Style Sheets Styles define how to display HTML elements Styles were added to HTML 4.0 to solve a problem External Style Sheets can save a lot of work External Style Sheets are stored in CSS files
CSS Demo
An HTML document can be displayed with different styles: See how it works
<h2>This header is blue</h2> <p>This paragraph has a left margin of 50 pixels</p> </body> </html>
This header is 36 pt
This is a header 1
You can see that the style sheet formats the text This is a link
CSS Syntax
A CSS rule has two main parts: a selector, and one or more declarations:
The selector is normally the HTML element you want to style. Each declaration consists of a property and a value. The property is the style attribute you want to change. Each property has a value.
CSS Example
A CSS declaration always ends with a semicolon, and declaration groups are surrounded by curly brackets: p {color:red;text-align:center;} To make the CSS more readable, you can put one declaration on each line, like this:
Example
p { color:red; text-align:center; } Try it yourself
CSS Comments
6
Comments are used to explain your code, and may help you when you edit the source code at a later date. Comments are ignored by browsers. A CSS comment begins with "/*", and ends with "*/", like this: /*This is a comment*/ p { text-align:center; /*This is another comment*/ color:black; font-family:arial; }
The id Selector
The id selector is used to specify a style for a single, unique element. The id selector uses the id attribute of the HTML element, and is defined with a "#". The style rule below will be applied to the element with id="para1":
Example
#para1 { text-align:center; color:red; } Try it yourself
Example
.center {text-align:center;} Try it yourself 8
<body> <h1 class="center">Center-aligned heading</h1> <p class="center">Center-aligned paragraph.</p> </body> </html> o/p:
Center-aligned heading
Center-aligned paragraph. You can also specify that only specific HTML elements should be affected by a class. In the example below, all p elements with class="center" will be center-aligned:
Example
p.center {text-align:center;}
Inline style
An external style sheet can be written in any text editor. The file should not contain any html tags. Your style sheet should be saved with a .css extension. An example of a style sheet file is shown below:
hr {color:sienna;} p {margin-left:20px;} body {background-image:url("images/back40.gif");}
Do not leave spaces between the property value and the units! "margin-left:20 px" (instead
Inline Styles
An inline style loses many of the advantages of style sheets by mixing content with presentation. Use this method sparingly!
10
To use inline styles you use the style attribute in the relevant tag. The style attribute can contain any CSS property. The example shows how to change the color and the left margin of a paragraph:
<p style="color:sienna;margin-left:20px">This is a paragraph.</p>
And an internal style sheet has these properties for the h3 selector:
h3 { text-align:right; font-size:20pt; }
If the page with the internal style sheet also links to the external style sheet the properties for h3 will be:
color:red; text-align:right; font-size:20pt;
The color is inherited from the external style sheet and the text-alignment and the font-size is replaced by the internal style sheet.
Tip: Even multiple external style sheets can be referenced inside a single HTML document.
11
Cascading order
What style will be used when there is more than one style specified for an HTML element? Generally speaking we can say that all the styles will "cascade" into a new "virtual" style sheet by the following rules, where number four has the highest priority:
1. Browser default 2. External style sheet 3. Internal style sheet (in the head section) 4. Inline style (inside an HTML element)
So, an inline style (inside an HTML element) has the highest priority, which means that it will override a style defined inside the <head> tag, or in an external style sheet, or in a browser (a default value). Note: If the link to the external style sheet is placed after the internal style sheet in HTML
<head>, the external style sheet will override the internal style sheet!
CSS Background
CSS background properties are used to define the background effects of an element. CSS properties used for background effects:
background-color background-image background-repeat background-attachment background-position
Background Color
The background-color property specifies the background color of an element. The background color of a page is defined in the body selector:
Example
body {background-color:#b0c4de;} Try it yourself
Look at CSS Color Values for a complete list of possible color values. In the example below, the h1, p, and div elements have different background colors:
Example
h1 {background-color:#6495ed;} p {background-color:#e0ffff;} div {background-color:#b0c4de;} Try it yourself
Background Image
The background-image property specifies an image to use as the background of an element. By default, the image is repeated so it covers the entire element. The background image for a page can be set like this:
Example
body {background-image:url('paper.gif');} Try it yourself
Below is an example of a bad combination of text and background image. The text is almost not readable:
Example
body {background-image:url('bgdesert.jpg');} Try it yourself
Example
13
If the image is repeated only horizontally (repeat-x), the background will look better:
Example
body { background-image:url('gradient2.png'); background-repeat:repeat-x; } Try it yourself
Example
body { background-image:url('img_tree.png'); background-repeat:no-repeat; } Try it yourself
In the example above, the background image is shown in the same place as the text. We want to change the position of the image, so that it does not disturb the text too much. The position of the image is specified by the background-position property:
Example
14
Example
body {background:#ffffff url('img_tree.png') no-repeat right top;} Try it yourself
When using the shorthand property the order of the property values are:
background-color background-image background-repeat background-attachment background-position
It does not matter if one of the property values is missing, as long as the ones that are present are in this order. This example uses more advanced CSS. Take a look: Advanced example
More Examples
15
How to set a fixed background image This example demonstrates how to set a fixed background image. The image will not scroll with the rest of the page.
Text Color
The color property is used to set the color of the text. With CSS, a color is most often specified by:
a HEX value - like "#ff0000" an RGB value - like "rgb(255,0,0)" a color name - like "red"
Look at CSS Color Values for a complete list of possible color values. The default color for a page is defined in the body selector.
Example
16
For W3C compliant CSS: If you define the color property, you must also define the
background-color property.
Text Alignment
The text-align property is used to set the horizontal alignment of a text. Text can be centered, or aligned to the left or right, or justified. When text-align is set to "justify", each line is stretched so that every line has equal width, and the left and right margins are straight (like in magazines and newspapers).
Example
h1 {text-align:center;} p.date {text-align:right;} p.main {text-align:justify;} Try it yourself
Text Decoration
The text-decoration property is used to set or remove decorations from text. The text-decoration property is mostly used to remove underlines from links for design purposes:
Example
a {text-decoration:none;} Try it yourself
Example
17
h1 h2 h3 h4
Try it yourself
It is not recommended to underline text that is not a link, as this often confuses users.
Text Transformation
The text-transform property is used to specify uppercase and lowercase letters in a text. It can be used to turn everything into uppercase or lowercase letters, or capitalize the first letter of each word.
Example
p.uppercase {text-transform:uppercase;} p.lowercase {text-transform:lowercase;} p.capitalize {text-transform:capitalize;} Try it yourself
Text Indentation
The text-indentation property is used to specify the indentation of the first line of a text.
Example
p {text-indent:50px;} Try it yourself
18
More Examples
Specify the space between characters This example demonstrates how to increase or decrease the space between characters. Specify the space between lines This example demonstrates how to specify the space between the lines in a paragraph. Set the text direction of an element This example demonstrates how to change the text direction of an element. Increase the white space between words This example demonstrates how to increase the white space between words in a paragraph. Disable text wrapping inside an element This example demonstrates how to disable text wrapping inside an element. Vertical alignment of an image This example demonstrates how to set the vertical align of an image in a text.
text-shadow Specifies the shadow effect added to text texttransform unicode-bidi verticalalign Sets the vertical alignment of an element Controls the capitalization of text
CSS Links
Links can be styled in different ways.
Styling Links
Links can be styled with any CSS property (e.g. color, font-family, background, etc.). Special for links are that they can be styled differently depending on what state they are in. The four links states are:
a:link - a normal, unvisited link a:visited - a link the user has visited a:hover - a link when the user mouses over it a:active - a link the moment it is clicked
Example
a:link {color:#FF0000;} /* unvisited link */ a:visited {color:#00FF00;} /* visited link */ a:hover {color:#FF00FF;} /* mouse over link */ a:active {color:#0000FF;} /* selected link */ Try it yourself 20
When setting the style for several link states, there are some order rules:
a:hover MUST come after a:link and a:visited a:active MUST come after a:hover
Text Decoration
The text-decoration property is mostly used to remove underlines from links:
Example
a:link {text-decoration:none;} a:visited {text-decoration:none;} a:hover {text-decoration:underline;} a:active {text-decoration:underline;} Try it yourself
Background Color
The background-color property specifies the background color for links:
Example
a:link {background-color:#B2FF99;} a:visited {background-color:#FFFF85;} a:hover {background-color:#FF704D;} a:active {background-color:#FF704D;} Try it yourself
More Examples
Add different styles to hyperlinks This example demonstrates how to add other styles to hyperlinks.
21
Advanced - Create link boxes This example demonstrates a more advanced example where we combine several CSS properties to display links as boxes.
CSS Lists
The CSS list properties allow you to:
Set different list item markers for ordered lists Set different list item markers for unordered lists Set an image as the list item marker
List
In HTML, there are two types of lists:
unordered lists - the list items are marked with bullets ordered lists - the list items are marked with numbers or letters
With CSS, lists can be styled further, and images can be used as the list item marker.
Example
ul.a {list-style-type: circle;} ul.b {list-style-type: square;} ol.c {list-style-type: upper-roman;} ol.d {list-style-type: lower-alpha;} Try it yourself
Some of the values are for unordered lists, and some for ordered lists.
Example
ul { 22
The example above does not display equally in all browsers. IE and Opera will display the image-marker a little bit higher than Firefox, Chrome, and Safari. If you want the image-marker to be placed equally in all browsers, a crossbrowser solution is explained below.
Crossbrowser Solution
The following example displays the image-marker equally in all browsers:
Example
ul { list-style-type: none; padding: 0px; margin: 0px; } li { background-image: url(sqpurple.gif); background-repeat: no-repeat; background-position: 0px 5px; padding-left: 14px; } Try it yourself
Example explained:
For ul: For li: Set the URL of the image, and show it only once (no-repeat) Position the image where you want it (left 0px and down 5px) Position the text in the list with padding-left Set the list-style-type to none to remove the list item marker Set both padding and margin to 0px (for cross-browser compatibility)
It is also possible to specify all the list properties in one, single property. This is called a shorthand property. The shorthand property used for lists, is the list-style property:
Example
ul { list-style: square url("sqpurple.gif"); } Try it yourself
When using the shorthand property, the order of the values are:
list-style-type list-style-position (for a description, see the CSS properties table below) list-style-image
It does not matter if one of the values above are missing, as long as the rest are in the specified order.
More Examples
All the different list-item markers for lists This example demonstrates all the different list-item markers in CSS.
list-style-image Specifies an image as the list-item marker list-styleposition list-style-type Specifies if the list-item markers should appear inside or outside the content flow Specifies the type of list-item marker
CSS Tables
Table Borders
24
To specify table borders in CSS, use the border property. The example below specifies a black border for table, th, and td elements:
Example
table, th, td { border: 1px solid black; } Try it yourself
Notice that the table in the example above has double borders. This is because both the table and the th/td elements have separate borders. To display a single border for the table, use the border-collapse property.
Collapse Borders
The border-collapse property sets whether the table borders are collapsed into a single border or separated:
Example
table { border-collapse:collapse; } table,th, td { border: 1px solid black; } Try it yourself
Example
table { 25
Example
td { text-align:right; } Try it yourself
The vertical-align property sets the vertical alignment, like top, bottom, or middle:
Example
td { height:50px; vertical-align:bottom; } Try it yourself
Table Padding
To control the space between the border and content in a table, use the padding property on td and th elements:
26
Example
td { padding:15px; } Try it yourself
Table Color
The example below specifies the color of the borders, and the text and background color of th elements:
Example
table, td, th { border:1px solid green; } th { background-color:green; color:white; } example: <html> <head> <style type="text/css"> #customers { font-family:"Trebuchet MS", Arial, Helvetica, sans-serif; width:100%; border-collapse:collapse; } 27
#customers td, #customers th { font-size:1em; border:1px solid #98bf21; padding:3px 7px 2px 7px; } #customers th { font-size:1.1em; text-align:left; padding-top:5px; padding-bottom:4px; background-color:#A7C942; color:#ffffff; } #customers tr.alt td { color:#000000; background-color:#EAF2D3; } </style> </head>
28
<th>Company</th> <th>Contact</th> <th>Country</th> </tr> <tr> <td>Alfreds Futterkiste</td> <td>Maria Anders</td> <td>Germany</td> </tr> <tr class="alt"> <td>Berglunds snabbkp</td> <td>Christina Berglund</td> <td>Sweden</td> </tr> <tr> <td>Centro comercial Moctezuma</td> <td>Francisco Chang</td> <td>Mexico</td> </tr> <tr class="alt"> <td>Ernst Handel</td> <td>Roland Mendel</td> <td>Austria</td> </tr> <tr> <td>Island Trading</td>
29
<td>Helen Bennett</td> <td>UK</td> </tr> <tr class="alt"> <td>Kniglich Essen</td> <td>Philip Cramer</td> <td>Germany</td> </tr> <tr> <td>Laughing Bacchus Winecellars</td> <td>Yoshi Tannamuri</td> <td>Canada</td> </tr> <tr class="alt"> <td>Magazzini Alimentari Riuniti</td> <td>Giovanni Rovelli</td> <td>Italy</td> </tr> <tr> <td>North/South</td> <td>Simon Crowther</td> <td>UK</td> </tr> <tr class="alt"> <td>Paris spcialits</td> <td>Marie Bertrand</td>
30
31
Example2: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <style type="text/css"> caption {caption-side:bottom;} </style> </head>
<body>
<table border="1"> <caption>Table 1.1 Customers</caption> <tr> <th>Company</th> <th>Contact</th> <th>Country</th> </tr> <tr> <td>Alfreds Futterkiste</td> <td>Maria Anders</td> <td>Germany</td> </tr> <tr> <td>Berglunds snabbkp</td> 32
<td>Christina Berglund</td> <td>Sweden</td> </tr> <tr> <td>Centro comercial Moctezuma</td> <td>Francisco Chang</td> <td>Mexico</td> </tr> <tr> <td>Ernst Handel</td> <td>Roland Mendel</td> <td>Austria</td> </tr> <tr> <td>Island Trading</td> <td>Helen Bennett</td> <td>UK</td> </tr> <tr> <td>Magazzini Alimentari Riuniti</td> <td>Giovanni Rovelli</td> <td>Italy</td> </tr> <tr> <td>North/South</td> <td>Simon Crowther</td>
33
<p><b>Note:</b> IE8 supports the caption-side property if a !DOCTYPE is specified.</p> </body> </html> Repeat background image <html> <head> <style type="text/css"> body { background-image:url('gradient2.png'); background-repeat:repeat-x; } </style> </head>
34
<head> <style type="text/css"> body { margin-left:200px; background:#5d9ab2 url('img_tree.png') no-repeat top left; }
.container { text-align:center; }
.center_div { border:1px solid gray; margin-left:auto; margin-right:auto; width:90%; background-color:#d0f0f6; text-align:left; padding:8px; } </style> </head> Text wrape:
35
<p> This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. This is some text. </p>
</body> </html>
36
Control the letters in a text: <html> <head> <style type="text/css"> p.uppercase {text-transform:uppercase;} p.lowercase {text-transform:lowercase;} p.capitalize {text-transform:capitalize;} </style> </head>
<body> <p class="uppercase">This is some text.</p> <p class="lowercase">This is some text.</p> <p class="capitalize">This is some text.</p> </body> </html> Style of button borders: <html> <head> <style type="text/css"> p {border-style:solid;} p.none {border-bottom-style:none;} p.dotted {border-bottom-style:dotted;} p.dashed {border-bottom-style:dashed;} p.solid {border-bottom-style:solid;} p.double {border-bottom-style:double;} 37
p.groove {border-bottom-style:groove;} p.ridge {border-bottom-style:ridge;} p.inset {border-bottom-style:inset;} p.outset {border-bottom-style:outset;} </style> </head>
<body> <p class="none">No bottom border.</p> <p class="dotted">A dotted bottom border.</p> <p class="dashed">A dashed bottom border.</p> <p class="solid">A solid bottom border.</p> <p class="double">A double bottom border.</p> <p class="groove">A groove bottom border.</p> <p class="ridge">A ridge bottom border.</p> <p class="inset">An inset bottom border.</p> <p class="outset">An outset bottom border.</p> </body> </html> Changing of cursor <html> <body> <p>Mouse over the words to change the cursor.</p> <span style="cursor:auto">auto</span><br /> <span style="cursor:crosshair">crosshair</span><br /> <span style="cursor:default">default</span><br /> <span style="cursor:e-resize">e-resize</span><br /> <span style="cursor:help">help</span><br /> <span style="cursor:move">move</span><br /> 38
<span style="cursor:n-resize">n-resize</span><br /> <span style="cursor:ne-resize">ne-resize</span><br /> <span style="cursor:nw-resize">nw-resize</span><br /> <span style="cursor:pointer">pointer</span><br /> <span style="cursor:progress">progress</span><br /> <span style="cursor:s-resize">s-resize</span><br /> <span style="cursor:se-resize">se-resize</span><br /> <span style="cursor:sw-resize">sw-resize</span><br /> <span style="cursor:text">text</span><br /> <span style="cursor:w-resize">w-resize</span><br /> <span style="cursor:wait">wait</span><br /> </body> </html> Set the browser automatically <html> <head> <style type="text/css"> div { background-color:#00FFFF; width:150px; height:150px; overflow:auto; } </style> </head>
<body>
39
<p>The overflow property decides what to do if the content inside an element exceeds the given width and height properties.</p>
<div> You can use the overflow property when you want to have better control of the layout. Try to change the overflow property to: visible, hidden, scroll, or inherit and see what happens. The default value is visible. </div> </body> </html> Horizontal menu <html> <head> <style type="text/css"> ul { float:left; width:100%; padding:0; margin:0; list-style-type:none; } a { float:left; width:6em; text-decoration:none; color:white; background-color:purple; padding:0.2em 0.6em;
40
<body> <ul> <li><a href="#">Link one</a></li> <li><a href="#">Link two</a></li> <li><a href="#">Link three</a></li> <li><a href="#">Link four</a></li> </ul>
<p> In the example above, we let the ul element and the a element float to the left. The li elements will be displayed as inline elements (no line break before or after the element). This forces the list to be on one line. The ul element has a width of 100% and each hyperlink in the list has a width of 6em (6 times the size of the current font). We add some colors and borders to make it more fancy. </p>
ul { list-style-type:none; margin:0; padding:0; overflow:hidden; } li { float:left; } a:link,a:visited { display:block; width:120px; font-weight:bold; color:#FFFFFF; background-color:#98bf21; text-align:center; padding:4px; text-decoration:none; text-transform:uppercase; } a:hover,a:active { background-color:#7A991A; }
</style> 42
</head>
<body> <ul> <li><a href="#home">Home</a></li> <li><a href="#news">News</a></li> <li><a href="#contact">Contact</a></li> <li><a href="#about">About</a></li> </ul> </body> </html>
43
Properties
Properties are the values associated with an object. In the following example we are using the length property of the String object to return the number of characters in a string: <script type="text/javascript"> var txt="Hello World!"; document.write(txt.length); </script> The output of the code above will be: 12
Methods
Methods are the actions that can be performed on objects. In the following example we are using the toUpperCase() method of the String object to display a text in uppercase letters: <script type="text/javascript"> var str="Hello world!"; document.write(str.toUpperCase()); </script> The output of the code above will be: HELLO WORLD!
44
<script type="text/javascript">
document.write("<p>Blink: " + txt.blink() + " (does not work in IE, Chrome, or Safari)</p>");
</script>
Big: Hello World! Small: Hello World! Bold: Hello World! Italic: Hello World! Fixed: Hello World! Strike: Hello World! Fontcolor: Hello World! Fontsize:
Hello World!
Subscript: Hello World! Superscript: Hello World! Link: Hello World! Blink: Hello World! (does not work in IE, Chrome, or Safari)
Match() method: <html> <body>
46
<script type="text/javascript"> var str="Hello world!"; document.write(str.match("world") + "<br />"); document.write(str.match("World") + "<br />"); document.write(str.match("worlld") + "<br />"); document.write(str.match("world!")); </script>
</body> </html> O/P: world null null world! Replace the charecters in a string replace() <html> <body> <script type="text/javascript"> var str="Visit Microsoft!"; document.write(str.replace("Microsoft","W3Schools")); </script> </body> </html> O/P: Visit W3Schools! The indexof() method: How to return the position of the first found occurrence of a specified value in a string. <html> <body>
47
<script type="text/javascript"> var str="Hello world!"; document.write(str.indexOf("d") + "<br />"); document.write(str.indexOf("WORLD") + "<br />"); document.write(str.indexOf("world")); </script> </body> </html> O/P: 10 -1 6
RegExp Object
A regular expression is an object that describes a pattern of characters. Regular expressions are used to perform pattern-matching and "search-and-replace" functions on text.
Syntax
var patt=new RegExp(pattern,modifiers); or more simply: var patt=/pattern/modifiers; pattern specifies the pattern of an expression modifiers specify if a search should be global, case-sensitive, etc.
For a tutorial about the RegExp object, read our JavaScript RegExp Object tutorial.
Modifiers
Modifiers are used to perform case-insensitive and global searches:
Modifier i g 48 Description Perform case-insensitive matching Perform a global match (find all matches rather than stopping
Brackets
Brackets are used to find a range of characters:
Expression [abc] [^abc] [0-9] [A-Z] [a-z] [A-z] [adgk] [^adgk] (red|blue| green) Description Find any character between the brackets Find any character not between the brackets Find any digit from 0 to 9 Find any character from uppercase A to uppercase Z Find any character from lowercase a to lowercase z Find any character from uppercase A to lowercase z Find any character in the given set Find any character outside the given set Find any of the alternatives specified
Metacharacters
Metacharacters are characters with a special meaning:
Metacharacte Description r . \w \W \d \D \s 49 Find a single character, except newline or line terminator Find a word character Find a non-word character Find a digit Find a non-digit character Find a whitespace character
Find a non-whitespace character Find a match at the beginning/end of a word Find a match not at the beginning/end of a word Find a NUL character Find a new line character Find a form feed character Find a carriage return character Find a tab character Find a vertical tab character Find the character specified by an octal number xxx Find the character specified by a hexadecimal number dd Find the Unicode character specified by a hexadecimal number xxxx
Quantifiers
Quantifier n+ n* n? n{X} n{X,Y} n{X,} n$ ^n 50 Description Matches any string that contains at least one n Matches any string that contains zero or more occurrences of n Matches any string that contains zero or one occurrences of n Matches any string that contains a sequence of X n's Matches any string that contains a sequence of X to Y n's Matches any string that contains a sequence of at least X n's Matches any string with n at the end of it Matches any string with n at the beginning of it
?=n ?!n
Matches any string that is followed by a specific string n Matches any string that is not followed by a specific string n
ignoreCa Specifies if the "i" modifier is set se lastIndex The index at which to start the next match
multiline Specifies if the "m" modifier is set source The text of the RegExp pattern
51
Introduction to XML
XML was designed to transport and store data. HTML was designed to display data.
What is XML?
XML stands for EXtensible Markup Language XML is a markup language much like HTML XML was designed to carry data, not to display data XML tags are not predefined. You must define your own tags XML is designed to be self-descriptive XML is a W3C Recommendation
The note above is quite self descriptive. It has sender and receiver information, it also has a heading and a message body. But still, this XML document does not DO anything. It is just information wrapped in tags. Someone must write a piece of software to send, receive or display it.
52
XML is Everywhere
XML is now as important for the Web as HTML was to the foundation of the Web. XML is the most common tool for data transmissions between all sorts of applications. XML is used in many aspects of web development, often to simplify data storage and sharing.
In the real world, computer systems and databases contain data in incompatible formats. XML data is stored in plain text format. This provides a software- and hardware-independent way of storing data. This makes it much easier to create data that can be shared by different applications.
54
55