s
1. What is HTML?
HTML is short for Hyper Text Markup Language. HTML is the language used to create webpages. It is a markup language which means that it is used to “mark up” text to indicate how it should be displayed in a web browser.
2. What is an HTML tag?
An HTML tag is a code that tells a web browser how to display a certain piece of text or image. Every piece of content on a webpage is surrounded by HTML tags. For example, the tag
indicates that the enclosed text should be displayed as a paragraph. Thetag indicates that the enclosed text should be displayed in bold font.
3. What is an HTML element?
An HTML element is everything between the opening and closing tags of an HTML tag. For example, in the code
This is a paragraph
, “This is a paragraph” is the element. The
and
tags are the opening and closing tags respectively.
An HTMLelement can contain other elements, which are then referred to as nested elements. Nested elements must always be enclosed within their parent element’s opening and closing tags. For example, the code
This is a bold paragraph
contains two nested elements: and . The
tag surrounds both of these nested elements, and so it is referred to as the parent element. The tags surround the text “This is a bold paragraph”, and so they are referred to as child elements of the
element (because they are nested within it). Every HTML document must have a root element, which encloses all other elements on the page. The root element of an HTML document is always theelement (and its corresponding closing tag). All other elements must be nested within this root element. Any un-nested elements will not display in a web browser, and so will not be visible on your webpage!
4. How do I create an HTML document?
To create an HTML document, you must first createa text file using any text editor (such as Notepad or TextEdit). Once you have created your blank text file, you can then save it with an .htm or .html file extension (for example: myfile.htm or myfile.html). This will tell your computer that this file contains HTML code, and so it will open ina web browser when you double-click on it later! You can also save your file with a .txt extension if you wish (for example: myfile.txt), but then you will need to open it ina text editor such as Notepad or TextEdit every time you want to edit it – it will no longer open automatically in your web browser when double-clicked! Once you have saved your file, you can then start writingHTML code into it using any text editor – again, we recommend using either Notepad or TextEdit for this purpose (you can use whichever you feel most comfortable with). Just remember to save your file regularly while working on it! When you are finished writing your code, save your file one final time and then double-click on itto open it ina web browser – voila! You should now see your very own custom webpage! Of course, at this stage it may not look very exciting just yet – but don’t worry, we’ll cover how to add pictures, videos, links and other goodies into your webpage later on… 😉 One final note before we moveon: Always make sure that when saving your file, you use either the .htm or .html extension – if you forgetto do this (andsave your file with just a .txt extension), then none of yourHTML code will work properly when opened ina web browser! Your web browser will simply treat your page as plaintext instead of tryingto interpret all of those crazy characters as actualHTML code… :(5)
What are some basic rules for writing valid HTML?
Although there are many different typesofHTML tags that you can use inyour documents, there are also some basic rules which all validHTML tags must adhere too: 1) AllHTML tags must have acorrespondingclosing tag – except for certain emptytagswhich represent self-contained content (such as images) 2) Tags must be properly nestedwithin eachother – i) openingtags can neverbe placed insideclosingtags ii) Tags which encloseothertagsmust alwayshave matchingopeningand closingtagsIII Openingand closingtagsmust alwaysmatch eachother(elements cannotbe leftun-closed!) iv) Closingtagsmust alwayscomeafter anyopeningtagswhich they correspond too 3) Attributesmust bedeclaredwithin agivenelement’sopeningtag 4) All attribute values must be enclosed within quotation marks 5) DOCTYPEdeclarationsare neverrequiredinXHTMLdocuments 6) Commentscan betype dwithinabodyof XHTMLeither usingthe traditional/* */comment delimitersor by usingthe new XMLstyle 7 Following these simple ruleswill ensurethat allofyour pagesare wellformedand displayedcorrectlyin all modernweb browsers!6)