-
declaration doctype for HTML5 is
< !DOCTYPE html >
-
The text between < html > and < /html >
describes the web page
-
The text between and
is the visible page content
-
The text between < h1 > and < /h1 >
is displayed as a heading
-
The text between < p > and < /p >
is displayed as a paragraph
-
what are tags
- they describe document content
- are keywords (tag names) surrounded by angle brackets like < html >
- they normally come in pairs like < b > and < /b >
- The first tag in a pair is the start/opening tag, the second tag is the end/closing tag
- The browser does not display the HTML tags, but uses the tags to determine how the content of the HTML page is to be presented/displayed to the user
- always use lower case letters (although html5 accepts upper case)
-
< p >
- paragraphs are defined with the < p > tag
- The < p > element defines a paragraph in the HTML document
- has a start and end tag
- < p >This is a paragraph.< /p >
-
< br >
Use the < br > tag if you want a line break (a new line) without starting a new paragraph
-
The < br > element is an empty HTML element. It has no end tag
This is a para graph with line breaks
-
< a >
- links are defined with the < a > tag
- < a > tag defines a hyperlink
- A hyperlink (or link) is a word, group of words, or image that you can click on to jump to another document.When you move the cursor over a link in a Web page, the arrow will turn into a little hand
- The most important attribute of the < a > element is the href attribute, which indicates the link's destination
- The link address is specified in the href attribute.
- has a start and end tag
- < a href=“http://www.w3schools.com" >This is a link< /a >
- < a href="url">Link text(what will show on the browser)< /a >
- The "Link text" doesn't have to be text. It can be an image or any other HTML element
- By default, links will appear in all browsers as:
- An unvisited link is underlined and blue
- A visited link is underlined and purple
- An active link is underlined and red
-
target attribute
- specifies where to open the linked document
- < a href="http://www.w3schools.com/" target=“_blank" >Visit W3Schools!< /a >
- or < a target=“_blank” >
-
what are the 5 different values for the target attribute, and their meanings
- _blank opens the linked doc in a new window or tab
- _self opens the linked doc in the same frame as it was clicked (default)
- _parent opens the linked doc in the parent frame
- _top opens the linked doc in the full body of the window
- framename opens the linked doc in a named frame
-
id attribute used to create a bookmark
- Bookmarks are not displayed in any special way. They are invisible to the reader
- An anchor with an id inside an HTML document:
- < a id=“tips" >Useful Tips Section< /a >
- Create a link to the "Useful Tips Section" inside the same document:
- < a href=“#tips" >Visit the Useful Tips Section< /a >
- Or, create a link to the "Useful Tips Section" from another page:
- < a href=“http://www.w3schools.com/html_links.htm#tips" >
- Visit the Useful Tips Section< /a >
- Always add a trailing slash to subfolder references. If you link like this: href="http://www.w3schools.com/html", you will generate two requests to the server, the server will first add a slash to the address, and then create a new request like this: href="http://www.w3schools.com/html/"
-
< title >
- Define a title for an HTML document
Use the < title > tag to define a title for a document
- must be placed within the < head >< /head> tags
- < title >this is the title of the HTML doc< /title >
-
< base >
Default URL and target for all links
Use the < base > tag to specify a default URL and a default target for all links on a page
-
< meta >
Provide metadata for an HTML document
Use < meta > elements to specify a description, keywords, author, and character set of a document
-
< img >
- images are defined with the < img > tag.
- The filename and the size of the image are provided as attributes
- < img src="w3schools.jpg" alt="W3Schools.com" width=“104" height=“142" >
-
HTML
- Hyper Text Markup Language
- is a markup language
- markup language is a set of markup tags
-
< html >
- is an element that defines the whole HTML document
- has a start and end tag
-
Element
- represents some kind of structure or semantics
- HTML tags" and "HTML elements" are often used to describe the same thing.But strictly speaking, an HTML element is everything between the start tag and the end tag, including the tags:< p >This is a paragraph.< /p >
- 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
- Most HTML elements can be nested (can contain other HTML elements)
- HTML documents consist of nested HTML elements, including “< html >”(which is an element itself) which consists of both start and end tags< html >< /html >
-
Empty Elements
elements with no content are called empty elements
-
< body >
- is an element that defines the body of the HTML document
- has a start and end tag
- The text between < body > and < /body > is the visible page content
-
< head >
- is an element that is a container for all the head elements
- Elements inside < head > can include scripts, instruct the browser where to find style sheets, provide meta information, and more
-
what tags can be added to the < head > section
< title >, < style >, < meta >, < link >, < script >, < noscript >, and < base >
-
< title >
- is a tag that defines the title of the document
- is placed within the < head > element
- The < title > element is required in all HTML/XHTML documents
- defines a title in the browser toolbar
- provides a title for the page when it is added to favorites
- displays a title for the page in search-engine results
-
< base >
- a tag that specifies the base URL/target for all relative URLs in a page
- placed within the < head > element
- < base href="http://www.w3schools.com/images/" target=“_blank" >
- < link >
- a tag that defines the relationship between a document and an external resource
- mostly used to link to style sheets
- found within the element
- < link rel="stylesheet" type="text/css" href=“mystyle.css" >
- < style >
- tag is used to define style information for an HTML document
- Inside the < style > element you specify how HTML elements should render in a browser
- < style type=“text/css" >
- body {background-color:yellow;}
- p {color:blue;}
- < /style >
-
< meta >
- Metadata is data (information) about data
- The < meta > 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
- The metadata can be used by browsers (how to display content or reload page), search engines (keywords), or other web services
- always placed within the < head > element
- Define keywords for search engines:
- < meta name="keywords" content="HTML, CSS, XML, XHTML, JavaScript” >
- Define a description of your web page:
- meta name="description" content="Free Web tutorials on HTML and CSS” >
- Define the author of a page:
- < meta name="author" content="Hege Refsnes” >
- Refresh document every 30 seconds:
- < meta http-equiv="refresh" content=“30” >
-
< script >
is a tag used to define a client-side script, such as a JavaScript
-
Attributes
- defines a property for an element
- appears within the elements start tag
- provide additional information about an element
- Attributes are always specified in the start tag
- Attributes come in name/value pairs like name=“value”
- Attribute values should always be enclosed in quotes.
- Double style quotes are the most common, but single style quotes are also allowed
- In some rare situations, when the attribute value itself contains quotes, it is necessary to use single quotes: name='John "ShotGun" Nelson’
- should use lowercase attribute names and values (although they are case insensitive)
-
class
Specifies one or more classnames for an element (refers to a class in a style sheet)
-
The class attribute is mostly used to point to a class in a style sheet. However, it can also be used by a JavaScript (via the HTML DOM) to make changes to HTML elements with a specified class
Note that this is an important paragraph.
-
id
The id attribute specifies a unique id for an HTML element (the value must be unique within the HTML document).
-
The id attribute is mostly used to point to a style in a style sheet, and by JavaScript (via the HTML DOM) to manipulate the element with the specific id.
< p id=“makeaname” >
-
style
Specifies an inline CSS style for an element
-
title
Specifies extra information about an element (displayed as a tool tip)
-
headings
- Headings are defined with the < h1 > to < h6 > tags
- < h1 > defines the most important heading. < h6 > defines the least important heading
- Browsers automatically add some empty space (a margin) before and after each heading
- Use HTML headings for headings only. Don't use headings to make text BIG or bold
- Search engines use your headings to index the structure and content of your web pages
- Since users may skim your pages by its headings, it is important to use headings to show the document structure
- H1 headings should be used as main headings, followed by H2 headings, then the less important H3 headings, and so on.
-
< hr >
- a tag that creates a horizontal line in an HTML page
- The hr element can be used to separate content
- < p >This is a paragraph.< /p >
- < hr >
- < p >This is a paragraph.< /p >
- < hr >
- < p >This is a paragraph.< /p >
-
< !-- This is a comment — >
There is an exclamation point after the opening bracket, but not before the closing bracket
-
Comments can be inserted into the HTML code to make it more readable and understandable. Comments are ignored by the browser and are not displayed
-
global attributes
Any attributes permitted globally.
-
DOM
Document Object Model
-
Semantics
allowing you to describe more precisely what your content is.
-
< section >
is an element that represents a section of a document, typically with a title or heading
-
< section >
- < h1>Heading< /h1 >
- < p>Bunch of awesome content< /p >
- < /section >
-
How to View HTML Source
Have you ever seen a Web page and wondered "Hey! How did they do that?"
-
To find out, right-click in the page and select "View Source" (IE) or "View Page Source" (Firefox), or similar for other browsers. This will open a window containing the HTML code of the page
-
-
< em >
Defines emphasized text, rendered in browser as italics
-
< i >
Defines a part of text in an alternate voice or mood
-
< small >
Defines smaller text
-
< strong >
Defines important text, rendered in browsers as bold
-
< sub >
Defines subscripted text
-
< sup >
Defines superscripted text
-
< ins >
Defines inserted text
-
< del >
Defines deleted text
-
< mark >
Defines marked/highlighted text
-
< code >
Defines computer code text
-
< kbd >
Defines keyboard text
-
< samp >
Defines sample computer code
-
< var >
Defines a variable
-
< pre >
Defines preformatted text
-
< abbr >
Defines an abbreviation or acronym
-
< address >
Defines contact information for the author/owner of a document
-
< bdo >
Defines the text direction
-
< blockquote >
Defines a section that is quoted from another source
-
< q >
Defines an inline (short) quotation
-
< cite >
Defines the title of a work
-
< dfn >
Defines a definition term
-
CSS
- Cascading Style Sheets
- used to style HTML elements
-
CSS can be added to HTML in 3 ways. Which are
- Inline - using the style attribute in HTML elements
- Internal - using the < style > element in the < head > section
- External - using an external CSS file
- The preferred way to add CSS to HTML, is to put CSS syntax in separate CSS files
-
Inline 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.
< p style=“color:blue;margin-left:20px;" >This is a paragraph.< /p >
-
Background Color
- The background-color property defines the background color for an element
- < body style=“background-color:yellow;" >
- < h2 style=“background-color:red;" >This is a heading< /h2 >
- < p style=“background-color:green;" >This is a paragraph.< /p >
- HTML Style Example for Font, Color, and Size
A headingA paragraph. - The font-family, color, and font-size properties make the old tag obsolete
-
HTML Style, Text Alignment:
The text-align property specifies the horizontal alignment of text in an element
-
< h1 style="text-align:center;">Center-aligned heading< /h1 >
The text-align property makes the old < center > tag obsolete
-
Internal Style Sheet
- can be used if one single document has a unique style.
- Internal styles are defined in the < head > section of an HTML page, by using the < style > tag, like this
- < head >
- < style type=“text/css" >
- body {background-color:yellow;}
- p {color:blue;}
- < /style >
- < /head >
-
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 < link > tag. The < link > tag goes inside the < head > section
- < head >
- < link rel="stylesheet" type="text/css" href=“mystyle.css" >
- < /head >
-
< style >
defines style information for a document
-
< link >
defines the relationship between a document and an external resource
-
Deprecated Tags and Attributes
In HTML 4, several tags and attributes were used to style documents. These tags are not supported in newer versions of HTML
-
Avoid using the elements: < font >, < center >, and < strike >, and the attributes: color and bgcolor
-
< img >
- images are defined with the
tag - The < img > 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.
- < img src="url" alt=“some_text" >
- If an HTML file contains ten images - eleven files are required to display the page right. Loading images takes time, so my best advice is: Use images carefully
- When a web page is loaded, it is the browser, at that moment, that actually gets the image from a web server and inserts it into the page. Therefore, make sure that the images actually stay in the same spot in relation to the web page, otherwise your visitors will get a broken link icon. The broken link icon is shown if the browser cannot find the image
-
Where does the browser place an image when using the < img > tag
The browser displays the image where the  tag occurs in the document. If you put an image tag between two paragraphs, the browser shows the first paragraph, then the image, and then the second paragraph
-
What is the alt attribute
The required alt attribute specifies an alternate text for an image, if the image cannot be displayed
-
The value of the alt attribute is an author-defined text
< img src="smiley.gif" alt="Smiley face” >
-
What are some reasons for alternate info being shown instead of the image
- because of slow connection
- an error in the src attribute
- if the user uses a screen reader
-
What attributes are used to specify the size of an image
- The height and width attributes
- The attribute values are specified in pixels by default
- < img src="smiley.gif" alt="Smiley face" width="42" height=“42" >
-
Why is it a good practice to specify both the height and width attributes for an image
-
If these attributes are set, the space required for the image is reserved when the page is loaded
without these attributes, the browser does not know the size of the image. The effect will be that the page layout will change during loading (while the images load)
-
< map >
Defines an image-map
-
< area >
Defines a clickable area inside an image-map
-
< tables >
- Tables are defined with the < table > tag.
- A table is divided into rows (with the < tr > tag), and each row is divided into data cells (with the < td> tag). td stands for "table data," and holds the content of a data cell. A < td > tag can contain text, links, images, lists, forms, other tables, etc.
-
Tables and Borders
- If you do not specify a border attribute, the table will be displayed without borders. Sometimes this can be useful, but most of the time, we want the borders to show.
- To display a table with borders, specify the border attribute:
- < table border=“1" >
- HTML Table Headers use what tag
- Header information in a table are defined with the < th > tag.
- All major browsers display the text in the < th > element as bold and centered
-
< table >
Defines a table
-
< th >
Defines a header cell in a table
-
< tr >
Defines a row in a table
-
< td >
Defines a cell in a table
-
< caption >
Defines a table caption
-
< colgroup >
Specifies a group of one or more columns in a table for formatting
-
< col >
Specifies column properties for each column within a |