Tuesday, October 16, 2018

HTML

What is HTML



The definition of HTML is HyperText Markup Language
  • HyperText is the method by which you move around on the web — by clicking on the special text called hyperlinks which bring you to the next page. The fact that it is hyper just means it is not linear — i.e. you can go to any place on the Internet whenever you want by clicking on links — there is no set order to do things in.
  • Markup is what HTML tags do to the text inside them. They mark it as a certain type of text (italicized text, for example).
  • HTML is a Language, as it has code-words and syntax like any other language


HTML Versions

Since the early days of the web, there have been many versions of HTML:

VersionYear
HTML1991
HTML 2.01995
HTML 3.21997
HTML 4.011999
XHTML2000
HTML52014

HTML Editors


Write HTML Using Notepad or TextEdit


Web pages can be created and modified by using professional HTML editors.

However, for learning HTML we recommend a simple text editor like Notepad (PC) or TextEdit (Mac).

We believe using a simple text editor is a good way to learn HTML.

Follow the four steps below to create your first web page with Notepad or TextEdit.



Step 1: Open Notepad (PC)


Windows 8 or later:

Open the Start Screen (the window symbol at the bottom left on your screen). Type Notepad.

Windows 7 or earlier:
Open Start > Programs > Accessories > Notepad


Step 1: Open TextEdit (Mac)


Open Finder > Applications > TextEdit
Also, change some preferences to get the application to save files correctly. In Preferences > Format > choose "Plain Text"
Then under "Open and Save", check the box that says "Display HTML files as HTML code instead of formatted text".
Then open a new document to place the code.


Step 1: Open TextEdit (Mac)


Open Finder > Applications > TextEdit
Also, change some preferences to get the application to save files correctly. In Preferences > Format > choose "Plain Text"
Then under "Open and Save", check the box that says "Display HTML files as HTML code instead of formatted text".
Then open a new document to place the code.


A Simple HTML Document

<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>

<h1>My First Heading</h1>
<p>My first paragraph.</p>

</body>
</html>


  • The <!DOCTYPE html> declaration defines this document to be HTML5
  • The <html> element is the root element of an HTML page
  • The <head> element contains meta information about the document
  • The <title> element specifies a title for the document
  • The <body> element contains the visible page content
  • The <h1> element defines a large heading
  • The <p> element defines a paragraph


Step 3: Save the HTML Page


Save the file on your computer. Select File > Save as in the Notepad menu.

Name the file "index.htm" and set the encoding to UTF-8 (which is the preferred encoding for HTML files).


Step 4: View the HTML Page in Your Browser


Open the saved HTML file in your favorite browser.


HTML Tags


HTML tags are element names surrounded by angle brackets.

<tagname>content goes here...</tagname>


  • HTML tags normally come in pairs like <p> and </p>
  • The first tag in a pair is the start tag, the second tag is the end tag
  • The end tag is written like the start tag, but with a forward slash inserted before the tag name


HTML Documents


All HTML documents must start with a document type declaration: <!DOCTYPE html>.
The HTML document itself begins with <html> and ends with </html>.

The visible part of the HTML document is between <body> and </body>.


HTML Headings


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


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

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



HTML Links


HTML links are defined with the <a> tag.

<a href="https://comtechls.blogspot.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.
You will learn more about attributes in a later chapter.


HTML Images


HTML images are defined with the <img> tag.
The source file (src), alternative text (alt), width, and height are provided as attributes.

<img src="w3schools.jpg" alt="comtechls.blogspot.com" width="104"height="142">

HTML Buttons

HTML buttons are defined with the <button> tag.

<button>Click me</button>



HTML Lists


HTML lists are defined with the <ul> (unordered/bullet list) or the <ol>(ordered/numbered list) tag, followed by <li> tags (list items).


<ul>
  <li>Coffee</li>
  <li>Tea</li>
  <li>Milk</li>
</ul>




HTML Elements


An HTML element usually consists of a start tag and end tag, with the content inserted in between.

<tagname>Content goes here...</tagname>


Nested HTML Elements



HTML elements can be nested (elements can contain elements).
All HTML documents consist of nested HTML elements.

<!DOCTYPE html>
<html>
<body>

<h1>My First Heading</h1>
<p>My first paragraph.</p>

</body>
</html>

The <html> element defines the whole document.
It has a start tag <html> and an end tag </html>.
The element content is another HTML element (the <body> element).


Do Not Forget the End Tag


Some HTML elements will display correctly, even if you forget the end tag.

The example above works in all browsers, because the closing tag is considered optional.

Never rely on this. It might produce unexpected results and/or errors if you forget the end tag.



Empty HTML Elements


HTML elements with no content are called empty elements.
<br> is an empty element without a closing tag (the <br> tag defines a line break).
Empty elements can be "closed" in the opening tag like this: <br />.

HTML5 does not require empty elements to be closed. But if you want stricter validation, or if you need to make your document readable by XML parsers, you must close all HTML elements properly.



Use Lowercase Tags


HTML tags are not case sensitive: <P> means the same as <p>



HTML Attributes


Attributes provide additional information about HTML elements.


AttributeDescription
altSpecifies an alternative text for an image, when the image cannot be displayed
disabledSpecifies that an input element should be disabled
hrefSpecifies the URL (web address) for a link
idSpecifies a unique id for an element
srcSpecifies the URL (web address) for an image
styleSpecifies an inline CSS style for an element
titleSpecifies extra information about an element (displayed as a tool tip)



The href Attribute


HTML links are defined with the <a> tag. The link address is specified in the href attribute.

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



The src Attribute


HTML images are defined with the <img> tag.
The filename of the image source is specified in the src attribute

<img src="img_girl.jpg">




The width and height Attributes


Images in HTML have a set of size attributes, which specifies the width and height of the image.

<img src="img_girl.jpg" width="500" height="600">




The alt Attribute


The alt attribute specifies an alternative text to be used, when an image cannot be displayed.

<img src="img_girl.jpg" alt="Girl with a jacket">



The style Attribute


The style attribute is used to specify the styling of an element, like color, font, size etc.

<p style="color:red">I am a paragraph</p>



The lang Attribute


The language of the document can be declared in the <html> tag.
The language is declared with the lang attribute.
Declaring a language is important for accessibility applications (screen readers) and search engines.


<!DOCTYPE html>
<html lang="en-US">
<body>

...

</body>
</html>



The title Attribute


Here, a title attribute is added to the <p> element. The value of the title attribute will be displayed as a tooltip when you mouse over the paragraph.


<p title="I'm a tooltip">
This is a paragraph.
</p>






References: 

idownloadblog.com
yourhtmlsource.com
w3school

0 comments:

Post a Comment