HTML Tutorial PDF

Document Details

ShinyTragedy

Uploaded by ShinyTragedy

Mansoura University

Tags

HTML web development web pages markup language

Summary

This document provides a comprehensive introduction to HTML, covering basic concepts, tags, and attributes. It explains how to create web pages using HTML, emphasizing the structure and purpose of various HTML elements. It also details how to use attributes to enhance the functionality and display of web pages.

Full Transcript

Chapter (1) HTML What is HTML? HTML is a language for describing web pages.. HTML stands for Hyper Text Markup Language. HTML is a markup language. A markup language is a set of markup tags. The tags describe document content. HTML documents contain HTML tags and plain tex...

Chapter (1) HTML What is HTML? HTML is a language for describing web pages.. HTML stands for Hyper Text Markup Language. HTML is a markup language. A markup language is a set of markup tags. The tags describe document content. HTML documents contain HTML tags and plain text HTML documents are also called web pages HTML Tags HTML markup tags are usually called HTML tags. HTML tags are keywords (tag names) surrounded by angle brackets like. HTML tags normally come in pairs like and. The first tag in a pair is the start tag, the second tag is the end tag 1. The end tag is written like the start tag, with a slash before the tag name. Start and end tags are also called opening tags and closing tags content Web Browsers:- The purpose of a web browser (such as Google Chrome, Internet Explorer, Firefox, Opera) is to read HTML documents and display them as web pages. The browser does not display the HTML tags, but uses the tags to determine how the content of the HTML page will be presented/displayed to the user. HTML can be edited by using a professional HTML editor like:. Microsoft Expression Web. Adobe Dreamweaver. Coffeecup HTML Editor However, for learning HTML we recommend a text editor like Notepad (PC) or TextEdit (Mac). 2 Follow the 4 steps below to create your first web page with Notepad. Step 1 : Open Notepad To open Notepad in Windows 7 or earlier: Click Start. Select All Programs, then Accessories, and Click Notepad. To open Notepad in Windows 8 or later: Open the Start Screen then type Notepad. Step 2: Write HTML Codes Computer and Information Courses Web Programming Step 3: Save the HTML Page Save the file on your computer. Select File-> Save as in the Notepad menu. When saving an HTML file, use either the.htm or the.html file extension. There is no difference. 3 Step 4: View HTML Page in Your Browser Double-click on the HTML file, and the result will appear. HTML Elements HTML documents are defined by HTML elements. Start tag Element End content tag Web Programming Empty content HTML Element Syntax An HTML element starts with a start tag An HTML element ends with an end tag The element content is everything between the start and the end tag Some HTML elements have empty content Empty elements are closed in the start tag Most HTML elements can have attributes 4 Nested HTML Elements Most HTML elements can be nested (can contain other HTML elements). HTML documents consist of nested HTML elements. HTML Document Example Mansoura University The example above contains 3 HTML elements. HTML Example Explained 1. The element: Mansoura University The element defines a paragraph in the HTML document. The element has a start tag and an end tag. The element content is: Mansoura University. 2. The element: Mansoura University 5 The element defines the body of the HTML document. The element has a start tag and an end tag. The element content is another HTML element (a p element). 3. The element: This is my first example The element defines the whole HTML document. The element has a start tag and an end tag. The element content is another HTML element (the body element). Don't Forget the End Tag Some HTML elements might display correctly even if you forget the end tag: My name is Omar My family stay in Mansoura - EGYPT 6 The example above works in most browsers, because the closing tag is considered optional. Never rely on this. Many HTML elements will produce unexpected results and/or errors if you forget the end tag. Empty HTML Elements HTML elements with no content are called empty elements. is an empty element without a closing tag (the tag defines a line break). In XHTML, all elements must be closed. Adding a slash inside the start tag, like , is the proper way of closing empty elements in XHTML (and XML). HTML tags are not case sensitive: means the same as - Many web sites use uppercase HTML tags. HTML Attributes Attributes provide additional information about HTML elements. HTML Attributes. HTML elements can have attributes 7. Attributes provide additional information about an element. Attributes are always specified in the start tag. Attributes come in name/value pairs like: name="value" Attribute Example HTML links are defined with the tag. The link address is specified in the href attribute: Example This is a link Attribute values should always be enclosed in quotes. Double style quotes are the most common, but single style quotes are also allowed. Attribute names and attribute values are case-insensitive. HTML Headings Headings are important to show the document structure. Search engines use your headings to index the structure and content of your web pages. HTML headings are defined with the to tags. 8 Example No. 1-1 : Mansoura University Faculty of Computer and lnformation second Year h1 headings should be used as main headings, followed by less important h2 headings, and so on. HTML Lines The tag creates a horizontal line in an HTML page. The hr element can be used to separate contents: Example No. 1-2: Mansoura University Faculty of Computer and Information Sciences lnformation Systems Department 9 How to View HTML Source right-click in the page and select "View Source" (IE) or "View Page Source" (Firefox). This will open a window containing the HTML code of the page. HTML Output You cannot be sure how HTML will be displayed. Large or small screens, and resized windows will create different results. With HTML, you cannot change the output by adding extra spaces or extra lines in your HTML code. The browser will remove extra spaces and extra lines when the page is displayed. Any number of lines counts as one line, and any number of spaces count as one space. The browser ignores the layout in the HTML source code! 10 Example No. 1-3: Mansoura University. Faculty of Computer & Information Systems. Information Systems Department. Computer Science Department. Information Technology Department. Result: Mansoura University. Faculty of Computer & Information Systems. Information Systems Department. Computer Science Department. Information Technology Department. HTML Text Formatting This text is bold This text is italic This is computer output superscript This is subscript and 11 HTML Formatting Tags Ta Defines bold text Defines em hasized text Defines a part of text in an alternate mood Defines smaller text Defines inserted text Defines deleted text Example No. 1-4: This text is bold This text is strong This text is italic This text is emphasized This is computer output X 1 + X2 Operating System Computer Architecture Data Structure 12 Economics Web Programming HTML "Computer Output" Tags Defines com uter code text Defines sam le com uter code Defines a variable 13 HTML Citations, Quotations, and Definition Tags Taa Description Defines an abbreviation or acronym Defines contact information for the author/owner of a document Defines the text direction Defines a section that is quoted from another source Defines an inline (short) quotation Defines the title of a work Defines a definition term Address Define the contact information for the author of HTML document. Example No. 1-5: Written by www.elbakry.mans.edu.eg Emai I us Address: Box 31116, Mansoura university, Mansoura 14 Phone: +2 050 2223743 Abbreviations and acronyms Example No. 1-6: The CIS was founded in 1996. Can I get this ASAP ? The title attribute is used to show the spelled-out version when holding the mouse pointer over the acronym or abbreviation. Text direction How to change the text direction. Example No. 1-7: 15 If your browser supports bi-directional override (bdo), the next line will be written from the right to the left (rtl): Here is some Arabic text HTML Links HTML links are defined with the tag. Example CNN News Note: The link address is specified in the href attribute. 16 Example No. 1-8: CNN News Mansoura university 17 HTML Images HTML images are defined with the tag and the Src attribute. The tag is empty, which means that it contains attributes only, and has no closing tag. To display an image on a page, you need to use the src attribute. Src stands for "source". The value of the src attribute is the URL of the image you want to display. Syntax for defining an image: 25 HTML Links - The target Attribute The target attribute specifies where to open the linked document. This example will open the linked document in a new browser window or in a new tab: Visit Mansoura university _blank opens the linked document in a new window or tab _self opens the linked document in the same frame as it was clicked (this is default) The HTML Element The tag specifies the base URL/target for all relative URLs in a page: The HTML Element The tag defines the relationship between a document and an external resource. The tag is most used to link to style sheets: 26 The HTML Element Metadata is data (information) about data. The tag provides metadata about the HTML document. Metadata will not be displayed on the page, but will be machine parsable. Meta elements are typically used to specify page description, keywords, author of the document, last modified, and other metadata. tags always go inside the element. Tags - Examples of Use All meta information goes in the head section Example No. 1-15: 27 Open the page, and then make right click by mouse to get these information. The HTML Element The tag is used to define a client-side script, such as a JavaScript. HTML Styles - CSS Styling HTML with CSS CSS was introduced together with HTML 4, to provide a better way to style HTML elements. CSS can be added to HTML in the following ways:. lnline - using the style attribute in HTML elements. Internal - using the element in the section. External - using an external CSS file 28 The preferred way to add CSS to HTML, is to put CSS syntax in separate CSS files. The HTML Style Attribute The HTML style attribute has the following syntax: style="property: value" The property is a CSS property. The value is a CSS value. lnline Styles An inline style can be used if a unique style is to be applied to one single occurrence of an element. To use inline styles, use the style attribute in the relevant tag. The style attribute can contain any CSS property. The example below shows how to change the text color and the left margin of a paragraph: Mansoura University Example No. 1-16: EGYPT 29 HTML Style Example - Background Color The background-color property defines the background color for an element: Example No. 1-17: Second Year Courses HTML Style Example - Font, Color and Size The font-family, color, and font-size properties defines the font, color, and size of the text in an element: Example No. 1-18: Web Programming HTML CSS PHP JQuery 30 HTML Style Example - Text Alignment Example No. 1-19: Mansoura University Faculty of Computer and Information Sciences Internal Style Sheet An internal style sheet can be used if one single document has a unique style. Internal styles are characterized in the section of an HTML page, by using the tag. Example No. 1-20: body {background-color:yellow;color:red;} p {color:blue;} Mansoura University Dr. Hazem EI-Bakry 31 External Style Sheet An external style sheet is ideal when the style is applied to many pages. With an external style sheet, you can change the look of an entire Web site by changing one file. Each page must link to the style sheet using the tag. The tag goes inside the section: HTML Style Tags Tag Description Defines style information for a document Defines the relationship between a document and an outer resource 32

Use Quizgecko on...
Browser
Browser