Web Design
Web Design
A html file is divided into two sections: the HEAD and the BODY. They are defined by
two tags: <head> and <body>. In addition, every html file needs two specific tags: <!
doctype html> and <html>. So, the structure of any html file is:
<!doctype html>
<html> The tag html is a block tag and it represents the entire document
<head>
The head has some specific tags that provides information to
the browser but are not shown in the page
</head>
<body>
The tag body is a block tag and it represents the entire page (as
a box) visible on the screen. It will contain all the tags that make
up the entire web page
</body>
</html>
LET’S CREATE YOUR FIRST HTML FILE WITH KOMODO EDIT
When you run Komodo for the first time
you should see the screen on the left.
If you get a different screen click “cancel”
and, after that, Komodo should start as in
the picture.
If the main menu at the top of page is not there, then:
Press the “Alt” key on the keyboard
Select “View” “Toolbars”
click “Show Menubar”
<!doctype html>
Now you are ready to write HTML code in
<html>
the html file.
<head> The first thing to do is to prepare the
</head> general standard structure for the web
page by writing the few tags you see on
<body> the left.
</body> When finished save the file
</html>
HTML TAGS
A TAG tells the browser what content is to be inserted in the page (box, text, picture, etc)
Each content shown in the page needs its own tag – most tags are block tags (the browser
places the tag’s content as a box after the previous box), a few tags are inline tags (the
browser places the tag’s content in the same line next to another element)
A TAG must be opened and (in most cases) it must be closed
This is the most important tag – the tag div – and it is used to arrange
simple content or other boxes in a specific position within the page
< div> Opening div
Some CONTENT (picture, text, text-paragraph, video, box, etc.)
</div> Closing div
The structure above defines a div box inside which there can be
any other content, that is, any number of different tags (for pictures,
paragraphs, lists, etc) as well as other div tags
EXAMPLES
For example, the tag <img> inserts an image in the page; what image? Or
better, what file? In order to tell the browser what file is to be used, the
attribute src (short for source) is used
<img src=“filename.jpg”> The jpeg picture filename.jpg is inserted in the page
<a href=“filename.html”> What follows the tag a will open the page filename.html
when clicked
<img src=“filename.jpg” width=“200”> The jpeg picture filename.jpg is inserted in the page
with a width of 200px
<div id=“idname”> The div has an identity and it can be referred to as idname
TAGS’ ATTRIBUTES
There are two particularly important attributes:
The attribute id gives a tag a specific unique name. That name can be used in
css instead of the tagname. NO OTHER TAG CAN HAVE THE SAME ID NAME
The attribute class gives a tag a specific name. That name can be used in css
instead of thetotagname.
It is important MANY
understand TAGS
that the CAN
style HAVE
in css THE SAME
is applied CLASS NAME
to a particular element
which is defined by its tag. However, if a particular style is applied, for example, to a div
tag, then all divs in the page will get the same style.
If this is not what you want, both the id and the class attributes provide a way for you
to be able to distinguish a tag from another one with the same tagname (all the divs in
the page, for example) when applying the style
To achieve that you will apply the style to the idname or to the classname instead of
applying it to the tagname
STYLE PROPRIETIES
CSS proprieties are used to set the appearance of a box or of its content. A propriety tells the
browser how (with which style) a specific tag or a set of tags is to appear in the page.
When the same classname is the attribute of many tags, then by using a classname you
identify a set of tags
.classname {
propriety: value;
propriety: value; Any list of proprieties
propriety: value;
………
}
STYLE PROPRIETIES
CSS proprieties are used to set the appearance of a box or of its content. A propriety tells the
browser how (with which style) a specific tag or a set of tags is to appear in the page.
When the same classname is the attribute of many tags, then by using a classname you
identify a set of tags
3 examples are the following:
(1)
The p identifies a tagname
p{
(2)
color: red;
#box {
border: solid green;
width: 500px;
width: 60%; The # identifies box as an
height: 200px;
font-weight: bold; idname (not a tagname)
background-color: green;
}
The . identifies title as a
padding: 50px;
classname (not a tagname) margin-left; 20px;
}
(3)
.title { (1) The style is applied to all p tags in the document
font-size: 150%; (2) The style is applied to the only tag in the document with
text-align: center; attribute id = “box”
line-height: double; (3) The style is applied to all tags in the document with
} attribute class = “title”
STYLE PROPRIETIES
more examples:
(1) (2)
p, h1, div { #box p {
color: red; width: 500px;
border: solid green; height: 200px;
width: 60%; background-color: green;
font-weight: bold; padding: 50px;
} margin-left; 20px;
}
(3) (4)
.title, #box { h1, h2 {
font-size: 150%; color: red;
text-align: center; }
line-height: double;
} h2 {
text-align: center;
}
(1) The style is applied to all the p, all the h1, and all the div tags in the document
(2) The style is applied to all the p tags inside the only tag in the document with id = box
(3) The style is applied to all the tags in the document with class = title and to the only tag in the
document with id = box
(4) The text color is red in all the h1 and h2 tags, the text is centered only in all the h2 tags
STYLE PROPRIETIES
There lots of different proprieties.
Each propriety can have one or more different values
Examples
width - to set the width of a box - the width is set in 2 main ways:
pixels (px) width: 500px; fixed width
Percentage (%) width: 60%; flexible width (60% of the width of the containing box)
padding- to set some space between box’s content and box’s edges
Normally in pixels (px) padding-left: 10px; 10px space to the left of the box’s content
padding-right: 10px; 10px space to the right of the box’s content
padding-bottom: 10px; 10px space below the bottom of the box’s content
padding-top: 10px; 10px space above the top of the box’s content
padding: 10px; 10px space to all 4 sides of the box’s content
STYLE PROPRIETIES
There lots of different proprieties.
Each propriety can have one or more different values
Examples
color - to set the color of some text content – in general there are 2 ways to specify a color
use a name color: red; limited number of color-names
use a code color: A4BB78; billions of colors