Html unit 1.1
What is HTML?
HTML is the standard markup language for creating Web pages
HTML consists of a series of elements
HTML elements tell the browser how to display the content
HTML describes the structure of a Web page
HTML elements label pieces of content such as "this is a heading", "this is a paragraph", "this is a link", etc.
HTML stands for HyperText Markup Language and is a coding language used to create websites and web pages. HTML is used to create the structure and content of a website, including text, images, videos, and links. HTML consists of tags and elements that define how the content should be displayed on the web page. It is the foundation of all websites and is essential for creating and maintaining web content.
Html Structure
HTML has a basic structure that consists of a head and body section. The head section contains information about the document, such as the title, meta information, and CSS styles. The body section contains the actual content of the web page, including text, images, links, and other elements.
Here is an example of a basic HTML structure:
Code : 01
<!DOCTYPE html>
<html>
<head>
<title>
Example Page
</title>
</head>
<body>
<h1>
Welcome to my website
</h1>
<p>
This is a sample paragraph.
</p>
<img src="image.jpg" alt="Sample Image">
<a href="https://slk-computers.blogspot.com">
Visit Example Website
</a>
</body>
</html>
Output:-image-01
In this example, the <!DOCTYPE html> declaration specifies that this is an HTML5 document. The <html> tag is the root element and encloses all the other elements. The <head> tag contains information about the document, such as the title displayed in the browser tab. The <body> tag contains the content that will be displayed on the web page, including a heading, a paragraph, an image, and a link.
Element
HTML elements are the building blocks of a web page and are used to define the structure and content of the page. Some common HTML elements include:
· Headings: Used to create headings and subheadings on a web page. There are six levels of headings, from <h1> to <h6>, with <h1> being the largest and most important.
· Paragraphs: Used to create paragraphs of text on a web page. The <p> tag is used to enclose the text within the paragraph.
· Images: Used to add images to a web page. The <img> tag is used to specify the source of the image and its size.
· Links: Used to create links to other pages or websites. The <a> tag is used to specify the target URL and the text that will be displayed as the link.
· Lists: Used to create lists of items on a web page. There are two types of lists: unordered lists (<ul>) and ordered lists (<ol>).
· Tables: Used to create tables on a web page. The <table> tag is used to create the table, while the <tr> tag is used to create rows, and the <td> tag is used to create cells.
· Forms: Used to create forms on a web page. Forms allow users to input data and submit it to a server for processing.
These are just a few examples of the many HTML elements available. By using different combinations of these elements, web developers can create a wide range of content for websites and web pages.
Note:-<open tag> text </close tag> total this three open tag, text and close tag is called one element
Attributes
HTML attributes are additional information that can be added to an HTML element to specify its behavior or appearance. Attributes are added to elements in the form of name-value pairs within the element's opening tag.
For example,
the <img> tag has several attributes that can be used to specify the source of the image, its size, and its alt text:
<img src="image.jpg" alt="Sample Image" width="500" height="300">
In this example,
the "src" attribute specifies the source of the image, the "alt" attribute provides a description of the image for screen readers and other assistive technologies, and the "width" and "height" attributes specify the size of the image.
Some other common attributes include:
"class" and "id": Used to specify styles for elements using CSS.
"href": Used to specify the target URL for a link.
"name" and "value": Used to specify the name and value for form elements.
"style": Used to specify inline styles for an element.
"width" and "height": Used to specify the size of elements, such as images and tables.
HTML attributes play a crucial role in determining the behavior and appearance of elements on a web page. By using different combinations of attributes, web developers can create a wide range of content with different behaviors and styles.
Style
HTML style refers to the way in which HTML elements are visually presented on a web page. Style information can be added to HTML elements in several ways, including inline styles, internal stylesheets, and external stylesheets.
Inline styles are specified directly within an HTML element's opening tag using the "style" attribute.
For example:code:02
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>InLine style sheet</title>
</head>
<body>
<p style="font-size: 18px; color: blue;">
This is a sample paragraph.
</p>
</body>
</html>
Output:-image-02
<p style="font-size: 18px; color: blue;">This is a sample paragraph.</p>
Internal stylesheets are specified within the head section of an HTML document using the <style> tag.
For example:code:03
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Internal style sheet</title>
<style>
p {
font-size: 18px; color: red;
}
</style>
</head>
<body>
<p>
This is a sample paragraph.
</p>
</body>
</html>
Output:-image-03
<head> <style> p { font-size: 18px; color: blue; } </style> </head>
External stylesheets are specified in a separate .css file and linked to the HTML document using the <link> tag in the head section.
For example:
There are two program write index.html and externalstylesheet.css
First program:-code:04.1
index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Index.html (first program)</title>
<head> <link rel="stylesheet" type="text/css" href="externalstylesheet.css"> </head>
</head>
<body>
<h1>
This is a sample paragraph.
</h1>
<h2>
This is a sample paragraph.
</h2>
</body>
</html>
Second program:-code:04.2
externalstylesheet.css
h1 {
color: blue;
}
h2 {
color: red;
}
Ouput:-images-04
<head> <link rel="stylesheet" type="text/css" href="styles.css"> </head>
CSS (Cascading Style Sheets) is the most common language used to specify styles in HTML. CSS provides a powerful way to control the appearance of HTML elements, including colors, fonts, sizes, and layout.
By using styles in HTML, web developers can create a consistent look and feel across a website and easily change the appearance of elements in a centralized manner. Styles can also be used to enhance the accessibility of a web page by ensuring that content is properly displayed for users with disabilities.
HTML Meta Tags
DOCTYPE, title, link, meta and style
HTML Table Tags
table, tr, td, th, tbody, thead, tfoot, col, colgroup and caption
HTML Form Tags
form, input, textarea, select, option, optgroup, button, label, fieldset and legend
HTML Text Tags
<p>, <h1>, <h2>, <h3>, <h4>, <h5>, <h6>, <strong>, <em>, <abbr>, <acronym>, <address>, <bdo>, <blockquote>, <cite>, <q>, <code>, <ins>, <del>, <dfn>, <kbd>, <pre>, <samp>, <var> and <br>
HTML Link Tags
<a> and <base>
HTML Image and Object Tags
<img>, <area>, <map>, <param> and <object>
HTML List Tags
<ul>, <ol>, <li>, <dl>, <dt> and <dd>
Comments
Post a Comment