Quarter 1 Week 2 - Computer Programming 1

Download as pdf or txt
Download as pdf or txt
You are on page 1of 9

Republic of the Philippines

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

.NET PROGRAMMING WEEK 2

Learning Material (LECTURETTE)

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:

<p>My cat is <strong>very</strong> grumpy.</p>

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:

<p>My cat is <strong>very grumpy.</p></strong>

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 versus inline elements


There are two important categories of elements in HTML which you should know about. They
are block-level elements and inline elements.

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

School: SHS in San Nicholas III, Bacoor City


Address: Garnet St. Green Valley, San Nicolas III, City of Bacoor, Cavite
Telephone No: (046) 236 5729
Email: [email protected]
appear inside a paragraph of text, for example an <a> element (hyperlink) or emphasis
elements such as <em> or <strong>.

Take the following example:

<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.

School: SHS in San Nicholas III, Bacoor City


Address: Garnet St. Green Valley, San Nicolas III, City of Bacoor, Cavite
Telephone No: (046) 236 5729
Email: [email protected]
Empty elements
Not all elements follow the above pattern of an opening tag, content, and a closing tag. Some
elements consist only of a single tag, which is usually used to insert/embed something in the
document at the place it is included. For example, the <img> element embeds an image file
onto a page in the position it is included in:
<img src="https://raw.githubusercontent.com/mdn/beginner-html-site/gh-
pages/images/firefox-icon.png">
This would output the following on your page:

Note: Empty elements are also sometimes called void elements.

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.

An attribute should have:


⚫ A space between it and the element name (or the previous attribute, if the element
already has one or more attributes).
⚫ The attribute name, followed by an equal sign.
⚫ An attribute value, with opening and closing quote marks wrapped around it.

School: SHS in San Nicholas III, Bacoor City


Address: Garnet St. Green Valley, San Nicolas III, City of Bacoor, Cavite
Telephone No: (046) 236 5729
Email: [email protected]
Another example of an element is <a> — this stands for "anchor" and will make the piece of
text it wraps around into a hyperlink. This can take a number of attributes, but several are as
follows:

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">

The above HTML will give you a rendered output as follows:

School: SHS in San Nicholas III, Bacoor City


Address: Garnet St. Green Valley, San Nicolas III, City of Bacoor, Cavite
Telephone No: (046) 236 5729
Email: [email protected]
Omitting quotes around attribute values
When you look around the World Wide Web, you'll come across a number of strange markup
styles, including attribute values without quotes. This is allowable in certain circumstances,
but will break your markup in others. For example, if we revisit our link example from earlier,
we could write a basic version with only the href attribute, like this:
<a href=https://www.mozilla.org/>favorite website</a>
However, as soon as we add the title attribute in this style, things will go wrong:
<a href=https://www.mozilla.org/ title=The Mozilla homepage>favorite website</a>
At this point the browser will misinterpret your markup, thinking that the title attribute is
actually three attributes — a title attribute with the value "The", and two Boolean attributes,
Mozilla and homepage.

It is advice to always include the attribute quotes — it avoids such problems, and
results in more readable code too.

Single or double quotes?

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>

<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!

<a href="http://www.example.com'>A link to my example.</a>

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:

<a href="http://www.example.com" title="Isn't this fun?"> A link to my example.</a>

School: SHS in San Nicholas III, Bacoor City


Address: Garnet St. Green Valley, San Nicolas III, City of Bacoor, Cavite
Telephone No: (046) 236 5729
Email: [email protected]
However if you want to include a quote, within the quotes where both the quotes are of the
same type (single quote or double quote), you'll have to use HTML entities for the quotes. For
example, this will break:
<a href='http://www.example.com' title='Isn't this fun?'>A link to my example.</a>
So you need to do this:
<a href='http://www.example.com' title='Isn&#39;t this fun?'>A link to my example.</a>

Anatomy of an HTML document


That wraps up the basics of individual HTML elements, but they aren't very useful on their
own. Now we'll look at how individual elements are combined to form an entire HTML page:

<!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.

School: SHS in San Nicholas III, Bacoor City


Address: Garnet St. Green Valley, San Nicolas III, City of Bacoor, Cavite
Telephone No: (046) 236 5729
Email: [email protected]
3. <head></head>: The <head> element. This element acts as a container for all the
stuff you want to include on the HTML page, that isn't the content you are showing to
your page's viewers. This includes things like keywords and a page description that you
want to appear in search results, CSS to style our content, character set declarations, and
more. You'll learn more about this in the next article of the series.
4. <meta charset="utf-8">: This element specifies the character set for your document
to UTF-8, which includes most characters from the vast majority of human written
languages. Essentially, it can now handle any textual content you might put on it. There
is no reason not to set this, and it can help avoid some problems later.

References: Programming .NET Curriculum Guide, Programming .NET NCIII Training


Regulations, https://developer.mozilla.org/en-US/docs/Learn/HTML
www.w3schools.com HTML5Notes For Professional, Tutorials Point

Prepared by:

ROI M. FRANCISCO
SHS TEACHER II

Checked by:

DR. GERALDINE M. TABING

Master Teacher II

Approved by:

ADORANDO R. DARVIN

Principal II

School: SHS in San Nicholas III, Bacoor City


Address: Garnet St. Green Valley, San Nicolas III, City of Bacoor, Cavite
Telephone No: (046) 236 5729
Email: [email protected]
Republic of the Philippines
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

Worksheet in (.NET) Programming 11

Quarter 1 Week 2

Name: _____________________ Date:____________

Grade & Section: _____________ Teacher: _________

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.

II. General Instructions


Before doing this activity make sure to read the lecturette.

III. Material/s Needed:


1. Computer/s
2. Text Editor(Notepad, VSCode, Notepad++ or Sublime Text, etc.)
3. Web Browser(Google Chrome, Mozilla Firefox, etc.)
NOTE:Set up your first your workplace by downloading your web browser (if you
prefer Google Chrome, Mozilla Etc.) and Text Editor. You will submit this as your
output for the activity.

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

School: SHS in San Nicholas III, Bacoor City


Address: Garnet St. Green Valley, San Nicolas III, City of Bacoor, Cavite
Telephone No: (046) 236 5729
Email: [email protected]
Activity 1.2: Adding attributes to an element
1. You were about to print paragraph tags with anchor tags, the content should
be all the names of your subject and the subject teachers.
[Hint]: You can look your class schedule in posted in your classroom.
2. You are going to create a five (5) paragraph. The content of the paragraph are
the events happened before our class.
3. You are to travel to Cebu-Bohol Tour for a beach escapade. Since you are going,
you need a set of materials for the trip. List down all the items you need, create
a checklist beforehand, determine whether you already have each of the items,
and buy the items you do not yet have. Indicate at least 5 items.
4. What can you conclude from this activity?
5. How do you feel after doing the activities given in the module?

Activity 1.3: Adding some features to an HTML document

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

INSTRUCTIONS FOR THE STUDENTS:


• Save your file in “htm or “html” format only.
• The filename of your should be:
“<Last Name>, <First Name> - Laboratory Exercise 0<XX>”
• Upload the file in the Google Drive link provided by your programming teacher.

Prepared by:

ROI M. FRANCISCO
SHS TEACHER II

Checked by: Approved by:

DR. GERALDINE M. TABING ADORANDO R. DARVIN


Master Teacher II Principal II

School: SHS in San Nicholas III, Bacoor City


Address: Garnet St. Green Valley, San Nicolas III, City of Bacoor, Cavite
Telephone No: (046) 236 5729
Email: [email protected]

You might also like