Docsity

HTML Tags, Elements, and Attributes: A Comprehensive Guide, Lecture notes of Web Design and Development

Toggle sidebar
bg1
HTML (Hypertext Markup Language)
HTML is a markup language that is used to structure content on the web. HTML is not a
programming language but a markup language used to design and structure content on a web
page using tags.
Basic HTML Structure:
<!DOCTYPE html>
<html>
<head>
<title>My First Web Page</title>
</head>
<body>
● <!DOCTYPE html>
This is a doctype or document type declaration and not an html element. It is an
instruction that tells the web client about the version of markup language that the web
page has been written in. HTML 5 is the latest version of html that is used in creating and
rendering web pages.
● <html>
This is the root element and acts as a container for the entire content of a web page. It
also helps in language settings
● <head>
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download HTML Tags, Elements, and Attributes: A Comprehensive Guide and more Lecture notes Web Design and Development in PDF only on Docsity!

HTML (Hypertext Markup Language)

HTML is a markup language that is used to structure content on the web. HTML is not a programming language but a markup language used to design and structure content on a web page using tags.

Basic HTML Structure :

My First Web Page

●

This is a doctype or document type declaration and not an html element. It is an instruction that tells the web client about the version of markup language that the web page has been written in. HTML 5 is the latest version of html that is used in creating and rendering web pages.

●

This is the root element and acts as a container for the entire content of a web page. It also helps in language settings

●

This contains important metadata and instructions that aren’t visible to the user but they play a critical role in how the page functions, appears, and interacts with the outside world.

Metadata doesn't display directly on the webpage, but it affects how the page is handled. Examples of metadata include:

○ Title of the page (): Displays in the browser tab or title bar. ○ Character encoding (<meta charset="UTF-8">): Specifies the character encoding for the page (ensures proper display of special characters, like accents or emojis). ○ Description of the page (<meta name="description" content="...">): Often used by search engines to show a snippet of your page in search results. ○ Author (<meta name="author" content="...">): Identifies the creator of the page. ○ Viewport settings : <meta name="viewport" content="width=device-width, initial-scale=1.0"> is important for responsive design. It ensures that the page looks good on mobile devices by controlling the layout scaling.

Linking external resources:

○ CSS stylesheets : <link rel="stylesheet" href="style.css"> links an external CSS file to style the page. ○ JavaScript files : <script src="script.js"></script> can also be added here (though it's more common to place <script> tags at the end of the <body> tag for better performance). ○ Favicon : <link rel="icon" href="favicon.ico" type="image/x-icon"> links a small icon that appears in the browser tab. ○ Preloading resources : <link rel="preload" href="image.jpg" as="image"> can help preload critical resources (like images or fonts), improving the loading speed.

An element is a combination of both the opening and closing tag along with the content. Examples include: Welcome, ,

An attribute is additional information inside the opening tag. Examples include href in , src and alt in

Categories of HTML Elements:

Block level elements:

These are elements that take up the full width available (by default) and always start on a new line. They are called block elements because they block any elements that come before or after them causing them to be pushed down. Block elements can contain inline elements and other block elements.

Example tags used for block elements:

● __ – Generic container for grouping content. ●

– Represents a paragraph of text. ● _

, , , ... , _ – Header tags used for headings. ● _, _ – Lists (unordered or ordered). ● __ – List item (used within or ). ● __ – Represents a self-contained piece of content. ● __ – Used to define sections of a page. ● _, , _ – For structural elements in a page layout.

Inline elements:

These are elements that don’t start on a new line and only take up as much width as necessary. They flow with the content and can thus exist alongside other inline elements on the same line. They can only contain other inline elements.

Examples of tags used for inline elements:

● __ – Generic inline container, often used for styling parts of text. ● __ – Defines a hyperlink. ● – Defines important text (usually rendered as bold).

● __ – Defines emphasized text (usually rendered as italic). ● __ – Embeds an image within the content. ●
– Represents a line break. ● __ – Represents computer code. ● __ – Defines a label for an input element in forms.

Common HTML Tags :

1. Working with Text: ● Headings (...):

Headings are used to define the structure and hierarchy of text on a webpage. They are represented by h and a digit defining the size and attribute of the text element ranging from 1 to 6 with 1 being the most important and 6 as the least important.

Examples are: This is a heading

● Paragraphs (

):

This defines a block of text on a web page with similar or related content. Different paragraph tags result in different separated blocks on the web page. It is represented using the

tag.

Example:

This is my paragraph

● Line Break (
):

This is used to add a line break. It is an empty tag, which means it has no closing tag.

Example:

This is
now on a new line

● Preformatted Text ():

This is used to make text smaller. It is basically used for copyrights or side comments.

Example:

This is smaller text

● Superscript () and Subscript ():

These are used to superscript and subscript a piece of text.

Example:

This is top text

This is below text

● Deleted () and Inserted Text ():

The del tag is used to add a strikethrough line in a text. For any other text to be added after the del tag, we use the ins tag to note the inserted text.

Example:

This is deletedtext

3. Working with Lists:

A list is a collection of elements that are usually related. Lists can be ordered or unordered.

1. Ordered Lists () :

This is a list where the order and arrangement of elements in the list is of priority and importance. By default, the browser will automatically number the elements in the list. Elements in the list are represented using list items tag ().

Example:

**1. ** First step Second step Third step

** Output:**

**1. First step

  1. Second step
  2. Third step**

The style of numbering can be changed using the type attribute on the ordered list. Ordered lists can be numbered using any of the following: ● type="1": Numeric (default, 1, 2, 3…) ● type="A": Uppercase letters (A, B, C…) ● type="a": Lowercase letters (a, b, c…) ● type="I": Uppercase Roman numerals (I, II, III…) ● type="i": Lowercase Roman numerals (i, ii, iii…)

Example:

**2. ** First step Second step **Third step

Output:** A. First step B. Second step **C. Third step

  1. Unordered Lists** (): This is a type of list where the order and arrangement of elements in the list isn’t of very much significance. In the browser, elements are represented by bullet points by default. Elements in the list are represented using list items tag ().

Example:

**1. ** First step

width and height - They define the dimensions of the image. title - This provides text that acts as a tooltip when a user hovers over the image. align - This allows alignment of the image within a page vspace - This adds vertical space i.e on the top and bottom of the image. hspace - This adds horizontal space i.e on the left and right of the image. Example:

5. Working with Links:

● Hyperlinks/Links () :

A hyperlink is a clickable element that allows a user to navigate between different web pages or websites. It is represented using the anchor tag with the href attribute.

The target attribute specifies where the web page is to be displayed. E.g

● _self - Default. Opens the document in the same window/tab as it was clicked ● _blank - Opens the document in a new window or tab ● _parent - Opens the document in the parent frame ● _top - Opens the document in the full body of the window

Example: redirects to my.com website/web page

The color of a link is determined by some attributes available in the body tag. These attributes are:

alink - Sets color of an active link.

vlink - Sets color of a visited link.

6. Working with tabular Data:

● Tables: ():

This is used to display data in rows and columns. The table is created using the following elements:

● : Defines the table container. ● (Table Row): Represents a row in the table. ● (Table Header): Defines a table header cell. By default, text in a is bold and centered. ● (Table Data): Defines a standard table cell. ● : Defines a title for the table ● : Allows a cell to span across multiple rows ● : Allows a cell to span across multiple columns ● , , and : Used to group the table into header, body and footer.

Example:

Header 1 Header 2 Header 3

Data 1

2.

The quick **brown fox jumps over the lazy dog.

  1. Working with User Input:**

● Forms :

A form is a collection of different elements that enables a user to enter information to a web page. The different elements are all added under the tag and they include:

● : The main container for form elements. ● Input elements: ■ (types: text, password, checkbox, radio, date, etc.) ■ , ,

Example:

Name:

Email:

Message:

Submit

Attributes for Forms :

● action (where form data is sent) ● method (http method used when submitting data, GET, POST e.t.c) ● name (used to identify form data)

B. Vegetables ● Leafy i. Kale ii. Spinach ● Non-leafy a. Cabbage C. Meats ■ White meats iii. My First Table

Monday Tuesday Wednesday Thursday Friday SCS101 SCS104 SCS SCS104 SCS SCS SCS101 SCS102 SCS

iv. My Second Table

v. My Third Table

Monday Tuesday Wednesday Thursday Friday SCS101 SCS104 SCS SCS104 SCS SCS SCS101 SCS102 SCS

Monday Tuesday Wednesday Thursday Friday SCS101 SCS104 SCS105 i. Eat SCS104 ii. Sleep SCS SCS SCS101 SCS102 SCS

vi. My Forth Table

Monday Tuesday Wednesday Thursday Friday SCS101 SCS104 B R E A K

SCS105 L

U

N

C

H

SCS

SCS111 SCS104 SCS