Web Development: HTML & Css
Web Development: HTML & Css
Shermeen Adnan
HTML Iframes
• An iframe is used to display a web page within
a web page.
• Iframe Syntax
– An HTML iframe is defined with the <iframe> tag:
– <iframe src="URL"></iframe>
• The src attribute specifies the URL (web
address) of the inline frame page.
HTML Iframes
• Iframe - Set Height and Width
– Use the height and width attributes to specify the size of
the iframe.
– The attribute values are specified in pixels by default, but
they can also be in percent (like "80%").
– Example
• <iframe src="demo_iframe.htm" height="200" width="300"></ifra
me>
• Or you can use CSS to set the height and width of the
iframe:
– Example
• <iframe src="demo_iframe.htm" style="height:200px;width:300px
;"></iframe>
HTML Iframes
• Iframe - Remove the Border
– By default, an iframe has a border around it.
– To remove the border, add the style attribute and use
the CSS border property:
– Example
• <iframe src="demo_iframe.htm" style="border:none;"></ifram
e>
• With CSS, you can also change the size, style and
color of the iframe's border:
– Example
• <iframe src="demo_iframe.htm" style="border:2px solid
red;"></iframe>
HTML Iframes
• Iframe - Target for a Link
– The <iframe> creates an inline frame, which embeds an independent
HTML document into the current document.
– An iframe can be used as the target frame for a link.
– It has a block display
– The target attribute of the link must refer to the name attribute of the
iframe:
– Example
• <iframe src="demo_iframe.htm" id="iframe_a"></iframe>
h1 {
color: green;
}
CSS Text
• Text Alignment
– The text-align property is used to set the horizontal alignment of a text.
– A text can be left or right aligned, centered, or justified.
– Example
• h1 {
text-align: center;
}
h2 {
text-align: left;
}
h3 {
text-align: right;
}
div {
text-align: justify;
}
CSS Text
• Text Decoration
– The text-decoration property is used to set or remove decorations from text.
– It is not recommended to underline text that is not a link, as this often
confuses the reader.
– Example
• a {
text-decoration: none;
}
h1 {
text-decoration: overline;
}
h2 {
text-decoration: line-through;
}
h3 {
text-decoration: underline;
}
CSS Text
• 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;
}
CSS Text
• Text Indentation
– The text-indent property is used to specify the
indentation of the first line of a text:
– Example
p {
text-indent: 50px;
}
CSS Text
• Letter Spacing
– The letter-spacing property is used to specify the space
between the characters in a text.
– The following example demonstrates how to increase or
decrease the space between characters:
– Example
h1 {
letter-spacing: 3px;
}
h2 {
letter-spacing: -3px;
}
CSS Text
• Line Height
– The line-height property is used to specify the space
between lines:
– Example
p.small {
line-height: 0.8;
}
p.big {
line-height: 1.8;
}
CSS Text
• Text Direction • Word Spacing
– The direction property is – The word-spacing property
used to change the text is used to specify the
direction of an element: space between the words
in a text.
– Example
– Example
p {
direction: rtl; h1 {
word-spacing: 10px;
}
}
h2 {
word-spacing: -5px;
}
CSS Text
• Text Shadow • Image alignment
– The text-shadow property – The vertical-align property
adds shadow to text. allows image alignment
– The following example – Example
specifies the position of the img{
horizontal shadow (3px), the vertical-align: text-top;
position of the vertical
}
shadow (2px) and the color
of the shadow (red):
– Example img{
• h1 { vertical-align: text-bottom;
text-shadow: 3px 2px red; }
}
CSS Fonts
• Font Family
– The font family of a text is set with the font-family property.
– The font-family property should hold several font names as a "fallback"
system. If the browser does not support the first font, it tries the next
font, and so on.
– Start with the font you want, and end with a generic family, to let the
browser pick a similar font in the generic family, if no other fonts are
available.
– Note: If the name of a font family is more than one word, it must be in
quotation marks, like: "Times New Roman".
– Example
• p {
font-family: "Times New Roman", Times, serif;
}
CSS Fonts
• Font Style
– The font-style property is mostly used to specify italic text.
– This property has three values:
– normal - The text is shown normally
– italic - The text is shown in italics
– oblique - The text is "leaning" (oblique is very similar to italic, but less supported)
– Example
– p.normal {
font-style: normal;
}
p.italic {
font-style: italic;
}
p.oblique {
font-style: oblique;
}
CSS Fonts
• Font Size
• The font-size property sets the size of the text.
• The font-size value can be an absolute, or relative size.
• Absolute size:
• Sets the text to a specified size
• Does not allow a user to change the text size in all browsers (bad for
accessibility reasons)
• Absolute size is useful when the physical size of the output is known
• Relative size:
• Sets the size relative to surrounding elements
• Allows a user to change the text size in browsers
CSS Fonts
• Set Font Size With Pixels
– Setting the text size with pixels gives you full
control over the text size
– If you use pixels, you can still use the zoom tool to
resize the entire page.
– Example
h1 {
font-size: 40px;
}
CSS Fonts
• Set Font Size With Em
– To allow users to resize the text (in the browser menu), many
developers use em instead of pixels.
– It is possible to adjust the text size in all browsers.
– 1em is equal to the current font size. The default text size in
browsers is 16px. So, the default size of 1em is 16px.
– The size can be calculated from pixels to em using this
formula: pixels/16=em
– Example
h1 {
font-size: 2.5em; /* 40px/16=2.5em */
}
• Responsive Font Size
– The text size can be set with a vw unit, which
means the "viewport width".
– Example
• <h1 style="font-size:10vw">Hello World</h1>
• Viewport is the browser window size. 1vw =
1% of viewport width. If the viewport is 50cm
wide, 1vw is 0.5cm.
CSS Fonts
• Font Weight
– The font-weight property specifies the weight of a font:
• Example
– p {
font-weight: normal;
}
p {
font-weight: bold;
}
CSS Fonts
• Font Variant
– The font-variant property specifies whether or not a text should
be displayed in a small-caps font.
– In a small-caps font, all lowercase letters are converted to
uppercase letters. However, the converted uppercase letters
appears in a smaller font size than the original uppercase letters in
the text.
– Example
p.normal {
font-variant: normal;
}
p.small {
font-variant: small-caps;
}