HTML
HTML
Note: Some HTML elements have no content (like the <br> element).
Windows 8 or later:
Open the Start Screen (the window symbol at the bottom left on
your screen). Type Notepad.
Windows 7 or earlier:
<!DOCTYPE html>
<html>
<body>
</body>
</html>
HTML Documents
1. All HTML documents must start with a document type
declaration: <!DOCTYPE html>.
2. It must only appear once, at the top of the page (before any
HTML tags).
Example
<a href="https://www.google.com">This is a link</a>
1. The link's destination is specified in the href attribute.
Example
HTML Images
1. HTML images are defined with the <img> tag.
2. The source file (src), alternative text (alt), width,
and height are provided as attributes:
Example
<img src="w3schools.jpg" alt="W3Schools.com" width="104" h
eight="142">
Example
HTML Elements
1. An HTML element is defined by a start tag, some content, and an
end tag.
2. The HTML element is everything from the start tag to the end
tag:
1. <tagname>Content goes here...</tagname>
Example
Empty HTML Elements
1. HTML elements with
no content are
Example
called empty
elements.
The <a> tag defines a hyperlink. The href attribute specifies the
URL of the page the link goes to:
The src Attribute
Example
<img src="img_girl.jpg">
There are two ways to specify the URL in the src attribute:
1. Absolute URL -
A. Links to an external image that is hosted on another website.
a) Example: src="https://www.w3schools.com/images/img_girl.jpg".
Notes:
1. External images might be under copyright.
2. If you do not get permission to use it, you may be in violation of copyright
laws.
3. In addition, you cannot control external images; it can suddenly be
removed or changed.
2. Relative URL -
A. Links to an image that is hosted within the website.
B. Here, the URL does not include the domain name.
C. If the URL begins without a slash, it will be relative to the current page.
A. Example: src="img_girl.jpg". If the URL begins with a slash, it will be
relative to the domain. Example: src="/images/img_girl.jpg".
The width and height Attributes
The <img> tag should also contain the width and height attributes,
which specify the width and height of the image (in pixels):
Example
<img src="img_girl.jpg" width="500" height="600">
Example
All HTML elements can have attributes
•The href attribute of <a> specifies the URL of the page the link goes
to
•The width and height attributes of <img> provide size information for
images
•The lang attribute of the <html> tag declares the language of the Web
page
.
HTML Headings
1. HTML headings are titles or subtitles that you want to display on a
webpage.
3. <h1> defines the most important heading. <h6> defines the least
important heading
Note: Use HTML headings for headings only. Don't use headings to
make text BIG or bold.
Bigger Headings
2. However, you can specify the size for any heading with
the style attribute, using the CSS font-size property:
<!DOCTYPE html> Example
<html>
<body>
<h1 style="font-size:60px;">Heading 1</h1>
<p>You can change the size of a heading with the style attribute,
using the font-size property.</p>
</body>
</html>
HTML Paragraphs
1. The HTML <p> element defines a paragraph.
</body>
</html>
HTML Line Breaks
1. The HTML <br> element defines a line break.
<p>
</p>
</body>
</html>
Solution - The HTML <pre> Element
<pre>
My Bonnie lies over the ocean.
</body>
</html>
HTML Styles
The HTML style attribute is used to add styles to an element,
such as color, font, size, and more.
<!DOCTYPE html> Example
<html>
<body>
<p>I am normal</p>
<p style="color:red;">I am red</p>
<p style="color:blue;">I am blue</p>
<p style="font-size:50px;">I am big</p>
</body>
</html>
The HTML Style Attribute
1. Setting the style of an HTML element, can be done with
the style attribute.
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
<!DOCTYPE html>
<html> Example
<body>
<h1 style="background-
color:powderblue;">This is a
heading</h1>
<p style="background-
color:tomato;">This is a
paragraph.</p>
</body>
</html>
Text Color
1. The CSS color property defines the text color for an
HTML element:
<!DOCTYPE html> Example
<html>
<body>
<h1 style="color:blue;">This is a
heading</h1>
<p style="color:red;">This is a
paragraph.</p>
</body>
</html>
Fonts
The CSS font-family property defines the font to be used for an HTML element:
<!DOCTYPE html>
<html> Example
<body>
<h1 style="font-
family:verdana;">This is a
heading</h1>
<p style="font-
family:courier;">This is a
paragraph.</p>
</body>
</html>
Text Size
The CSS font-size property defines the text size for an
HTML element:
Text Alignment
Example
HTML Formatting Elements
Formatting elements were designed to display special types of text:
3. Tip: Use the global title attribute to show the description for
the abbreviation/acronym when you mouse over the
element.
HTML <address> for Contact
Information
1. The HTML <address> tag defines the contact information for
the author/owner of a document or an article.
1. The HTML <cite> tag defines the title of a creative work (e.g.
a book, a poem, a song, a movie, a painting, a sculpture, etc.).
• Comments can be
used to hide content.
• This can be helpful if
you hide content
temporarily:
Hide Inline Content
• Comments
can be used to
hide parts in
the middle of
the HTML
code.
HTML Colors