Beruflich Dokumente
Kultur Dokumente
HTML tags are keywords (tag names) surrounded by angle brackets like <html>
HTML tags normally come in pairs like <b> and </b>
The first tag in a pair is the start tag, the second tag is the end tag
The end tag is written like the start tag, with a forward slash before the tag name
Start and end tags are also called opening tags and closing tags
<a name="s3"><h3>section3</h3></a>
<pre>Write something in section 3.
Let us describe item1 in section3.
Suppose item3 is blue in color.</pre>
<a href="#s1">section1</a><br>
<a href="#s2">section2</a><br>
<a href="#s3">section3</a><br>
e. Hyper graphics: A graphic on a web page which is also a hyperlink is called a hyper graphic.
f. Address footer and E-mail : Email can be added as a last sentence (footer) in a page as follows.
<a href="mailto:pranand12@gmail.com?subject=comments">E-mail a comment</a>
2.8 Fonts Colors and Colorful and Textured Backgrounds
<body bgcolor="Yellow">
<font color="red" size=1>One</font><br>
<font color="green" size=2>Two</font><br>
<font color="blue" size=3>Three</font><br>
</body>
2.9 Working with tables
<table border=1>
<tr>
<th>table header1</th> <th>table header2</th>
</tr>
<tr>
<td>table data11</td> <td>table data12</td>
</tr>
<tr>
<td>table data21</td> <td>table data22</td>
</tr>
</table>
Tags you add inside other tags inherit the outer tags formatting, unless you specify otherwise. For example, if
you define a <BODY> style, any tags you nest within the <BODY> tags inherit that formatting. This is called
cascading.
b.Style Sheet Rules
c. CSS selectors
There are three types of selectors. (i) element
(ii)id
(iii)class.
The element selector selects elements based on the element name.
<html>
<head>
<style>
p{
text-align: center;
color: red;
}
</style>
</head>
<body>
<p>Every paragraph will be affected by the style.</p>
<p>Me too!</p>
<p>And me!</p>
</body>
</html>
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#".
<html>
<head>
<style>
#para1 {
text-align: center;
color: red;
}
</style>
</head>
<body>
<p id="para1">Hello World!</p>
<p>This paragraph is not affected by the style.</p>
</body>
</html>
5
The class selector is used to specify a style for a group of elements. Unlike the id selector, the class
selector is most often used on several elements.
The class selector uses the HTML class attribute, and is defined with a "."
<html>
<head>
<style>
.center {
text-align: center;
color: red;
}
</style>
</head>
<body>
<h1
class="center">Red
heading</h1>
<p
class="center">Red
paragraph.</p>
and
center-aligned
and
center-aligned
</body>
</html>
To minimize the code, you can group selectors. To group selectors, separate each selector with a comma.
<html>
<head>
<style>
h1, h2, p {
text-align: center;
color: red;
}
</style>
</head>
<body>
<h1>Hello World!</h1>
<h2>Smaller heading!</h2>
<h3>This is not affected</h3>
<p>This is a paragraph.</p>
</body>
</html>
d.Style Properties
i. Font and Text properties
<p style="color:red;text-align:center;
text-transform:uppercase;
text-decoration:underline; ">
Welcome to All
</p>
<html>
<head>
<style>
div {
background-color: lightgrey;
width: 200px;
padding: 20px;
border: 15px solid navy;
margin: 25px;
}
</style>
</head>
<body>
<div>The CSS box model is essentially
a box that wraps around HTML
elements, and it consists of: margins,
borders, padding, and the actual
content.</div>
</body>
</html>
7
Positioning
The CSS positioning properties allow you to position an element.
Elements can be 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 positioning method.
There are four different positioning methods.
Static Positioning
HTML elements are positioned static by default. A static positioned element is always positioned according to the
normal flow of the page.
Static positioned elements are not affected by the top, bottom, left, and right properties.
Fixed Positioning
An element with fixed position is positioned relative to the browser window.
It will not move even if the window is scrolled
<html>
<head>
<style>
p.pos_fixed {
position: fixed;
top: 30px;
right: 5px;
color: red;
}
</style>
</head>
<body>
<p>Some
text</p><p>Some
text</p><p>Some text</p><p>Some
text</p><p>Some text</p><p>Some
text</p><p>Some text</p><p>Some
text</p><p>Some text</p><p>Some
text</p><p>Some text</p>
text</p><p>Some
text</p><p>Some
text</p><p>Some
text</p><p>Some
text</p><p>Some
Absolute Positioning
With absolute positioning, an element can be placed anywhere on a page.
<html>
<head>
<style>
h2 {
position: absolute;
left: 100px;
top: 150px;
}
</style>
</head>
<body>
<h2>This
heading
has
an
absolute
position</h2>
<p>With absolute positioning, an element can
be placed anywhere on a page. The heading
below is placed 100px from the left of the page
and 150px from the top of the page.</p>
</body>
</html>
iii. External
style.css in styles folder
h1{background:red;font-style:italic}
div{background:pink}
p{background:green}
ess.htm
<html>
<head>
</head>
<body>
<link rel = "stylesheet" href = "styles\style.css"
type="css">
<h1>CSS External style sheets example!</h1>
<div>
This is a text inside a div element.
<p>This paragraph has its own background
color.</p>
We are still in the div element.
</div>
</body>
</html>
iv. Imported
Another interesting way to add CSS to a HTML page is with the import rule. This lets us attach a new CSS file from
within CSS itself. Let's look at an example of how this is done then I will show a practical example of when you
might use this method. To import a new CSS file from within CSS simply use the following rule:
@import "newstyles.css";
Just change "newstyles" to the name of your CSS file and be sure to include the correct path to the file too. Remember
the path is relative to the current CSS file that we are in, if the CSS is embedded into the HTML page then the path is
relative to the HTML file.
Let's imagine we have a 1000 page website and we link to a CSS file from every page on the site. Now let's
imagine we want to add a second CSS file to all of those pages. We could edit all 1000 HTML files and add a second
CSS link or a much better way would be to import the second CSS file from within the first file. We just saved
ourselves many hours of work!
f. Style Inheritance
Inheritance is a key feature in CSS, - it relies on the ancestor-descendant relationship to operate. Inheritance is the
mechanism by which properties are applied not only to a specified element, but also to its descendants. Descendant
elements may inherit CSS property values from any ancestor element enclosing them. In general, descendant elements
inherit text-related properties, but box-related properties are not inherited. Properties that can be inherited are color,
font, letter-spacing, line-height, list-style, text-align text-indent, text-transform, visibility, white-space and wordspacing. Properties that cannot be inherited are background, border, display, float and clear, height and width, margin,
min- and max-height and -width, outline, overflow, padding, position, text-decoration, vertical-align and z-index.
10
Inheritance prevents certain properties from being declared over and over again in a style sheet, allowing the software
developers to write less CSS. It enhances faster-loading of web pages by users and enables the clients to save money
on bandwidth and development costs.
<style>h1{color: red;}</style>
<h1>This to <i>illustrate</i> inheritance</h1>
!important means 'this is important, ignore subsequent rules, and apply this rule!'
<style>
a {border:5px dotted green;
background: yellow;
}
</style>
<a style="border:1px solid red;background: gray;">Without
!important</a>
<style>
a {border:5px dotted green;
background: yellow !important; }
</style>
<a style="border:1px
!important</a>
solid
red;background:
gray;">With
CSS Provides you with, normally, six units with which to define the size of properties .
Unit: Pixels
Pixels define an element's size using a specific number of pixels. If your document is primarily designed for
print, then you may want to look at one of the other unit options.
Unit: Ems
Ems are a relative measurement unit. One 'Em'(1em) is equal to the height of the capital letter "M" in the
default font size.
Unit: Exes
Exes are similar to Ems, in that they are a relative unit of measurement that defines 1 unit to be equal to the
size of the letter "x" in the default font size
Units: Points and Picas
These units are print media units of measurments. A point (1pt) equals 1/72 of an inch, while a pica (1pc)
equals 1/6 of an inch. Documents intended for printed media will be able to tell the device exactly what the
intended size is for these units.
Unit: Percentages
When assigning percentage units to the font-size or line-height properties, they act like the Em unit,
where 100% equals 1em.
Ex:
<p style="font-size:10px">ten pixels</p>
<p style="font-size:10em">ten ems</p>
<p style="font-size:10ex">ten exs</p>
<p style="font-size:10pt">ten points</p>
<p style="font-size:10pc">ten picas</p>
<p style="font-size:50%">fifty % of M</p>
2.12 Introduction to XML
What is XML?
XML stands for EXtensible Markup Language
XML is a markup language much like HTML
XML was designed to carry and store data, not to display data
XML tags are not predefined. You must define your own tags
XML is designed to be self-descriptive
XML and HTML were designed with different goals:
XML was designed to transport and store data, with focus on what data is
HTML was designed to display data, with focus on how data looks
HTML is about displaying information, while XML is about carrying information.
XML does not DO anything. XML was created to store, and transport information.
The following example is a note to Tove, from Jani, stored as XML:
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
12
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.
XML Separates Data from HTML
If you need to display dynamic data in your HTML document, it will take a lot of work to edit the HTML each time
the data changes.
With XML, data can be stored in separate XML files. This way you can concentrate on using HTML/CSS for display
and layout, and be sure that changes in the underlying data will not require any changes to the HTML.
With a few lines of JavaScript code, you can read an external XML file and update the data content of your web page.
XML Simplifies Data 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.
XML supports Unicode
XML is a textual data format with strong support via Unicode for the languages of the world.
XML documents must be well-formed, meaning they should follow the syntax rules of the XML
specification. It is also possible (but not a requirement) for XML documents to be valid. A valid
XML document conforms to a Document Type Definition (DTD) or an XML Schema. A DTD or an
XML Schema dictates what elements and attributes may be part of a given XML document.
A schema is a formal way of defining and validating the content of an XML document. (A wellformed XML document that conforms to its schema is said to be valid.)
The schema is how we assign the data types to each tag and any attributes that are contained in the
XML document. A schema is a structured document which must obey XML syntax rules. It is
composed of a series of predefined tags and attributes that are part of the XML language and are
used to set the data types for the values associated with our custom tags. Simply put, not only do we
get to create custom XML tags, but we can also denote that an XML data value is, for example, an
integer data type. This ability to assign specific data types to specific XML data values is one of the
reasons why XML has attracted so much attention.
A schema can be part of the XML document or a separate file.
XML with correct syntax is "Well Formed" XML.
XML validated against a DTD or an XML Schema is "Valid" XML.
A "Well Formed" XML document has correct XML syntax.The syntax rules for XML documents are:
XML documents must have a root element
XML elements must have a closing tag
XML tags are case sensitive
XML elements must be properly nested
XML attribute values must be quoted
***
13