Quarter 1 Week 2 - Computer Programming 1
Quarter 1 Week 2 - Computer Programming 1
Quarter 1 Week 2 - Computer Programming 1
Department of Education
REGION IV-A CALABARZON
SCHOOLS DIVISION OF BACOOR CITY
SHS IN SAN NICHOLAS III, BACOOR CITY
SAN NICOLAS III, CITY OF BACOOR, CAVITE
Nesting elements
Elements can be placed within other elements too — this is called nesting. If we wanted to
state that our cat is very grumpy, we could wrap the word "very" in a <strong> element,
which means that the word is to be strongly emphasized:
You do however need to make sure that your elements are properly nested: in the example
above, we opened the p element first, then the strong element, therefore we have to close
the strong element first, then the p. The following is incorrect:
The elements have to open and close correctly, so they are clearly inside or outside one
another. If they overlap like above, then your web browser will try to make a best guess at
what you were trying to say, and you may well get unexpected results. So don't do it!
Block-level elements form a visible block on a page — they will appear on a new line from
whatever content went before it, and any content that goes after it will also appear on a new
line. Block-level elements tend to be structural elements on the page that represent, for
example, paragraphs, lists, navigation menus, footers, and so on. A block-level element
wouldn't be nested inside an inline element, but it might be nested inside another block-level
element.
Inline elements are those that are contained within block-level elements and surround only
small parts of the document’s content, not entire paragraphs and groupings of content. An
inline element will not cause a new line to appear in the document; they would normally
<em>first</em><em>second</em><em>third</em>
<p>fourth</p><p>fifth</p><p>sixth</p>
<em> is an inline element, so as you can see below, the first three elements sit on the same
line as one another with no space in between. On the other hand, <p> is a block-level
element, so each element appears on a new line, with space above and below each (the
spacing is due to default CSS styling that the browser applies to paragraphs).
firstsecondthird
fourth
fifth
Sixth
Note: HTML5 redefined the element categories in HTML5: see Element content categories.
While these definitions are more accurate and less ambiguous than the ones that went before,
they are a lot more complicated to understand than "block" and "inline", so we will stick with
these throughout this topic.
The terms "block" and "inline", as used in this topic, should not be confused with the types of
CSS boxes with the same names. While they correlate by default, changing the CSS display
type doesn't change the category of the element and doesn't affect which elements it can
contain and which elements it can be contained in. One of the reasons why HTML5 dropped
these terms was to prevent this rather common confusion.
Attributes
Elements can also have attributes, which look like this:
Attributes contain extra information about the element that you don't want to appear in the
actual content. In this case, the class attribute allows you to give the element an identifying
name, that can be used later to target the element with style information and other things.
href: This attribute's value specifies the web address that you want the link to point to;
where the browser navigates to when the link is clicked. For example,
href="https://www.mozilla.org/".
title: The title attribute specifies extra information about the link, such as what page is
being linked to. For example, title="The Mozilla homepage". This will appear as a tooltip when
the element is hovered over.
target: The target attribute specifies the browsing context that will be used to display the
link. For example, target="_blank" will display the link in a new tab. If you want to display
the link in the current tab, just omit this attribute.
Boolean attributes
You'll sometimes see attributes written without values — this is perfectly allowed. These are
called Boolean attributes, and they can only have one value, which is generally the same as
the attribute name. As an example, take the disabled attribute, which you can assign to form
input elements, if you want them to be disabled (grayed out) so the user can't enter any data
in them.
<input type="text" disabled="disabled">
As shorthand, it is perfectly allowable to write this as follows (we've also included a non-
disabled form input element for reference, to give you more of an idea what is going on):
<!-- using the disabled attribute prevents the end user from entering text into the input box
-->
<input type="text" disabled>
<!-- The user can enter text into the follow input, as it doesn't contain the disabled attribute
-->
<input type="text">
It is advice to always include the attribute quotes — it avoids such problems, and
results in more readable code too.
You'll notice that the attributes are all wrapped in double quotes. You might however see
single quotes in some people's HTML code. This is purely a matter of style, and you can feel
free to choose which one you prefer. Both the following lines are equivalent:
<a href="http://www.example.com">A link to my example.</a>
You should however make sure you don't mix them together. The following will go
wrong!
If you've used one type of quote in your HTML, you can include the other type of
quote inside your attribute values without causing any problems:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>My test page</title>
</head>
<body>
<p>This is my page</p>
</body>
</html>
Here we have:
1. <!DOCTYPE html>: The doctype. In the mists of time, when HTML was young (about
1991/2), doctypes were meant to act as links to a set of rules that the HTML page had to
follow to be considered good HTML, which could mean automatic error checking and other
useful things. They used to look something like this:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
However, these days no one really cares about them, and they are really just a historical
artifact that needs to be included for everything to work right. <!DOCTYPE html> is the
shortest string of characters that counts as a valid doctype; that's all you really need to know.
2. <html></html>: The <html> element. This element wraps all the content on the entire
page, and is sometimes known as the root element.
Prepared by:
ROI M. FRANCISCO
SHS TEACHER II
Checked by:
Master Teacher II
Approved by:
ADORANDO R. DARVIN
Principal II
Quarter 1 Week 2
I. Objectives
a. Identify the nesting elements, HTML attributes and anatomy of an HTML
Document;
b. Create HTML documents with nesting elements, empty elements, attributes
and HTML documents with complete basic parts;
c. Appreciate the importance of HTML elements, attributes and the anatomy of
an HTML Document in web development.
Procedure:
1. On the title of your webpage write the following:
Laboratory Exercise 0<XX>
<Last Name>, <First Name> | “I can do this!”<Date>
2. On the bottom part and use comment tags, write/type down your
understanding regarding the activities.
3. Keep your codes clean and secured until you complete the activities. Should
they be requested, present them accordingly. Should you fail to do so, you will
automatically receive zero (0) mark
1. You were about to copy the HTML page example listed in the anatomy of HTML
document.
2. Implement the following tasks:
• Just below the opening tag of the <body> element, add a main title for the
document.
• This should be wrapped inside an <h1> opening tag and </h1> closing tag.
• Edit the paragraph content to include some text about something you are
interested in.
• Make any important words stand out in bold by wrapping them inside a
<strong> opening tag and </strong> closing tag.
• Add a link to your paragraph.
• Add an image to your document, below the paragraph,
• You'll get bonus points if you manage to link to a different image (either locally
on your computer, or somewhere else on the web).
3. What can you conclude from this activity?
4. How do you feel after doing the activities given in the module
Prepared by:
ROI M. FRANCISCO
SHS TEACHER II