0% found this document useful (0 votes)
55 views

Theory of HTML

The document provides an introduction and overview of HTML, including definitions of common HTML elements (such as headings, paragraphs, links, images), how to view HTML source code in browsers, HTML attributes, colors, tables, CSS, and more. Key points covered include: - HTML is the standard markup language used to create web pages and describes the structure of a web page. - Common HTML elements include headings, paragraphs, links, images and these elements provide structure and meaning to the content on the page. - Attributes like href and src provide additional information about elements like links and images. - CSS can be used to style and lay out HTML elements with properties like color, font, size and more

Uploaded by

Sumer Dabby
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
55 views

Theory of HTML

The document provides an introduction and overview of HTML, including definitions of common HTML elements (such as headings, paragraphs, links, images), how to view HTML source code in browsers, HTML attributes, colors, tables, CSS, and more. Key points covered include: - HTML is the standard markup language used to create web pages and describes the structure of a web page. - Common HTML elements include headings, paragraphs, links, images and these elements provide structure and meaning to the content on the page. - Attributes like href and src provide additional information about elements like links and images. - CSS can be used to style and lay out HTML elements with properties like color, font, size and more

Uploaded by

Sumer Dabby
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

HTML 

Introduction
HTML is the standard markup language for creating Web pages.

What is HTML?
 HTML stands for Hyper Text Markup Language
 HTML is the standard markup language for creating Web pages
 HTML describes the structure of a Web page
 HTML consists of a series of elements
 HTML elements tell the browser how to display the content
 HTML elements label pieces of content such as "this is a heading", "this is a paragraph",
"this is a link", etc.

Example Explained

 The <!DOCTYPE html> declaration defines that this document is an HTML5 document


 The <html> element is the root element of an HTML page
 The <head> element contains meta information about the HTML page
 The <title> element specifies a title for the HTML page (which is shown in the browser's
title bar or in the page's tab)
 The <body> element defines the document's body, and is a container for all the visible
contents, such as headings, paragraphs, images, hyperlinks, tables, lists, etc.
 The <h1> element defines a large heading
 The <p> element defines a paragraph

HTML Headings
HTML headings are defined with the <h1> to <h6> tags.
<h1> defines the most important heading. <h6> defines the least important heading: 

Example
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>

HTML Paragraphs
HTML paragraphs are defined with the <p> tag:

Example
<p>This is a paragraph.</p>
<p>This is another paragraph.</p>

HTML Links
HTML links are defined with the <a> tag:

Example
<a href="https://www.w3schools.com">This is a link</a>

The link's destination is specified in the href attribute. 

Attributes are used to provide additional information about HTML elements.

HTML Images
HTML images are defined with the <img> tag.

The source file (src), alternative text (alt), width, and height are provided as attributes:
Example
<img src="image.jpg" alt="image.com" width="104" height="142">

How to View HTML Source?


Have you ever seen a Web page and wondered "Hey! How did they do that?"

View HTML Source Code:

Right-click in an HTML page and select "View Page Source" (in Chrome) or "View Source" (in
Edge), or similar in other browsers. This will open a window containing the HTML source code
of the page.

Inspect an HTML Element:

Right-click on an element (or a blank area), and choose "Inspect" or "Inspect Element" to see
what elements are made up of (you will see both the HTML and the CSS). You can also edit the
HTML or CSS on-the-fly in the Elements or Styles panel that opens.

HTML Attributes
HTML attributes provide additional information about HTML elements.

HTML Attributes
 All HTML elements can have attributes
 Attributes provide additional information about elements
 Attributes are always specified in the start tag
 Attributes usually come in name/value pairs like: name="value"

The href Attribute


The <a> tag defines a hyperlink. The href attribute specifies the URL of the page the link goes to:

Example
<a href="https://www.google.com">Visit google</a>

The src Attribute


The <img> tag is used to embed an image in an HTML page. The src attribute specifies the path
to the image to be displayed:

Example
<img src="img_girl.jpg">

There are two ways to specify the URL in the src attribute:

1. Absolute URL - Links to an external image that is hosted on another website.


Example: src="https://www.w3schools.com/images/img_girl.jpg".

2. Relative URL - Links to an image that is hosted within the website. Here, the URL does not
include the domain name. If the URL begins without a slash, it will be relative to the current
page. 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".

HTML Styles
The HTML style attribute is used to add styles to an element, such as color, font, size, and
more.

Example

I am Red

I am Blue
I am Big
The HTML Style Attribute
Setting the style of an HTML element, can be done with the style attribute.

The HTML style attribute has the following syntax:

<tagname style="property:value;">

Background Color
The CSS background-color property defines the background color for an HTML element.

Text Color
The CSS color property defines the text color for an HTML element:

Fonts
The CSS font-family property defines the font to be used for an HTML element:

HTML Colors
HTML colors are specified with predefined color names, or with RGB, HEX, HSL, RGBA,
or HSLA values.

Color Names
In HTML, a color can be specified by using a color name:
RGB Color Values
In HTML, a color can be specified as an RGB value, using this formula:

rgb(red, green, blue)

Each parameter (red, green, and blue) defines the intensity of the color with a value between 0
and 255.

This means that there are 256 x 256 x 256 = 16777216 possible colors!

For example, rgb(255, 0, 0) is displayed as red, because red is set to its highest value (255), and
the other two (green and blue) are set to 0.

Another example, rgb(0, 255, 0) is displayed as green, because green is set to its highest value
(255), and the other two (red and blue) are set to 0.

To display black, set all color parameters to 0, like this: rgb(0, 0, 0).

To display white, set all color parameters to 255, like this: rgb(255, 255, 255).

HEX Color Values


In HTML, a color can be specified using a hexadecimal value in the form:

#rrggbb

Where rr (red), gg (green) and bb (blue) are hexadecimal values between 00 and ff (same as
decimal 0-255).

For example, #ff0000 is displayed as red, because red is set to its highest value (ff), and the other
two (green and blue) are set to 00.

Another example, #00ff00 is displayed as green, because green is set to its highest value (ff), and
the other two (red and blue) are set to 00.
To display black, set all color parameters to 00, like this: #000000.

To display white, set all color parameters to ff, like this: #ffffff.

HTML Tables
HTML tables allow web developers to arrange data into rows and columns.

Table Cells
Each table cell is defined by a <td> and a </td> tag.

td stands for table data.

Everything between <td> and </td> are the content of the table cell.

Table Rows
Each table row starts with a <tr> and end with a </tr> tag.

tr stands for table row.

Table Headers
Sometimes you want your cells to be headers, in those cases use the <th> tag instead of
the <td> tag:
HTML Block and Inline
Elements
Every HTML element has a default display value, depending on what type of element it is.

There are two display values: block and inline.

Block-level Elements
A block-level element always starts on a new line.

A block-level element always takes up the full width available (stretches out to the left and right
as far as it can).

A block level element has a top and a bottom margin, whereas an inline element does not.

The <div> element is a block-level element.

Inline Elements
An inline element does not start on a new line.

An inline element only takes up as much width as necessary.

This is  a <span> element inside  a paragraph.

HTML class Attribute
The HTML class attribute is used to specify a class for an HTML element.
Multiple HTML elements can share the same class.

Using The class Attribute


The class attribute is often used to point to a class name in a style sheet. It can also be used by a
JavaScript to access and manipulate elements with the specific class name.

HTML id Attribute
The HTML id attribute is used to specify a unique id for an HTML element.

You cannot have more than one element with the same id in an HTML document.

Using The id Attribute


The id attribute specifies a unique id for an HTML element. The value of the id attribute must be
unique within the HTML document.

The id attribute is used to point to a specific style declaration in a style sheet. It is also used by
JavaScript to access and manipulate the element with the specific id.

The syntax for id is: write a hash character (#), followed by an id name. Then, define the CSS
properties within curly braces {}.

CSS Introduction
CSS is the language we use to style a Web page.

What is CSS?
 CSS stands for Cascading Style Sheets
 CSS describes how HTML elements are to be displayed on screen, paper, or in other
media
 CSS saves a lot of work. It can control the layout of multiple web pages all at once
 External stylesheets are stored in CSS files

CSS Selectors
A CSS selector selects the HTML element(s) you want to style.

CSS Selectors
CSS selectors are used to "find" (or select) the HTML elements you want to style.

We can divide CSS selectors into five categories:

 Simple selectors (select elements based on name, id, class)


 Combinator selectors (select elements based on a specific relationship between them)
 Pseudo-class selectors (select elements based on a certain state)
 Pseudo-elements selectors (select and style a part of an element)
 Attribute selectors (select elements based on an attribute or attribute value)

The CSS id Selector


The id selector uses the id attribute of an HTML element to select a specific element.

The id of an element is unique within a page, so the id selector is used to select one unique
element!

To select an element with a specific id, write a hash (#) character, followed by the id of the
element.

The CSS class Selector


The class selector selects HTML elements with a specific class attribute.

To select elements with a specific class, write a period (.) character, followed by the class name.

The CSS Universal Selector


The universal selector (*) selects all HTML elements on the page.

CSS Borders
The CSS border properties allow you to specify the style, width, and color of an element's
border.

CSS Border Style


The border-style property specifies what kind of border to display.

The following values are allowed:

 dotted - Defines a dotted border

 dashed - Defines a dashed border

 solid - Defines a solid border

 double - Defines a double border

 groove - Defines a 3D grooved border. The effect depends on the border-color value

 ridge - Defines a 3D ridged border. The effect depends on the border-color value

 inset - Defines a 3D inset border. The effect depends on the border-color value

 outset - Defines a 3D outset border. The effect depends on the border-color value

 none - Defines no border

 hidden - Defines a hidden border


CSS Margins
Margins are used to create space around elements, outside of any defined borders.

This element has a margin of 70px.

CSS Margins
The CSS margin properties are used to create space around elements, outside of any defined
borders.

With CSS, you have full control over the margins. There are properties for setting the margin for
each side of an element (top, right, bottom, and left).

Margin - Individual Sides


CSS has properties for specifying the margin for each side of an element:

 margin-top
 margin-right
 margin-bottom
 margin-left

All the margin properties can have the following values:

 auto - the browser calculates the margin


 length - specifies a margin in px, pt, cm, etc.
 % - specifies a margin in % of the width of the containing element
 inherit - specifies that the margin should be inherited from the parent element
CSS Padding
Padding is used to create space around an element's content, inside of any defined borders

This element has a padding of 70px.

CSS Padding
The CSS padding properties are used to generate space around an element's content, inside of any
defined borders.

With CSS, you have full control over the padding. There are properties for setting the padding for
each side of an element (top, right, bottom, and left).

Padding - Individual Sides


CSS has properties for specifying the padding for each side of an element:

 padding-top
 padding-right
 padding-bottom
 padding-left

CSS Layout - Overflow
The CSS overflow property controls what happens to content that is too big to fit into an area.

CSS Overflow
The overflow property specifies whether to clip the content or to add scrollbars when the content
of an element is too big to fit in the specified area.

The overflow property has the following values:

 visible - Default. The overflow is not clipped. The content renders outside the element's
box
 hidden - The overflow is clipped, and the rest of the content will be invisible

 scroll - The overflow is clipped, and a scrollbar is added to see the rest of the content

 auto - Similar to scroll, but it adds scrollbars only when necessary

CSS Layout - float and clear


The CSS float property specifies how an element should float.

The CSS clear property specifies what elements can float beside the cleared element and on
which side.

The float Property


The float property is used for positioning and formatting content e.g. let an image float left to the
text in a container.

The float property can have one of the following values:

 left - The element floats to the left of its container

 right - The element floats to the right of its container

 none - The element does not float (will be displayed just where it occurs in the text). This
is default
 inherit - The element inherits the float value of its parent

In its simplest use, the float property can be used to wrap text around images.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy