In the HTML syntax, most elements are written with a start tag and an end tag,
with the content in between.
An HTML tag is composed of the name of the tag (or command), surrounded by angle brackets.
An end tag also has a slash after the opening angle bracket, to distinguish it from the start tag.
<tagname> content </tagname>
For instance,
these tags
tell the content of the element how to display.
Thus, the element
<p>This is a paragraph</p>
tells the browser to show the words "This is a paragraph" as a paragraph, or
This is a paragraph
HTML tags follow the same logic as did UNIX/LINUX commands.
UNIX/LINUX ⇒ | command | argument | value |
HTML ⇒ | tag | attribute | value |
Working with UNIX/LINUX at the command line
requires us to know certain exact commands.
Working with HTML in the hard code
requires us to know certain exact tags.
We want to become comfortable with the fact that just as
some
UNIX/LINUX commands
require an argument to effectively
carry out the command,
so some
HTML tags
require an attribute to effectively
carry out the tag.
Sometimes the attribute will include a specific
value that must be appended to the
attribute in order to carry out the
tag.
tags block/inline headings lists para/line breaks differences
A block-level element always starts on a new line and takes up the full width available (stretches out to the left and right as far as it can).
Some examples of block level elements include
<div> a division or a section
<p> paragraph
<hn> headings, where "n" is a number, usually from 1 to 6
<ul> unordered and <ol> ordered lists
<li> list items
This is a paragraph with a background color to show the block.
An inline element does not start on a new line and only takes up as much width as necessary.
Some examples of inline elements include
<a> anchor
<b> bold or <strong> strong
<i> italics or <em> emphasis
<img> image
<span> is used to group inline-elements in a document
For example, this is a span in which the color of the text was changed, but it did not affect the remainder of the block element paragraph (which itself had its background color modified just to display the block).
tags block/inline headings lists para/line breaks differences
Tags for headings are of the style <hn> where n is replaced by a numeral between 1 and 6. The first pages we created use a Heading 1 for your name. Take a look at the code and how it displays.
<h1 style="text-align:center;"> Your Name </h1>
All of our pages use heading tags to identify different parts of the page
The tags tell the browser to display the text between the opening tags
<h1, h2, or h3 respectively>
and the closing tags
</h1, /h2, or /h3 respectively>
in the manner that the particular browser
chooses to display a Heading 1, a Heading 2, or a Heading 3
tags block/inline headings lists para/line breaks differences
W3Schools on HTML Lists
The basic list in HTML is the unordered list. The following shows the usage of list tags.
<ul> - the start tag
<li> - the tag for each item in the list,
followed by the end tag </li>
<li> - another list item
</li>
<li> - yet another
</li>
</ul> - the end tag
tags block/inline headings lists para/line breaks differences
<p>
- the tag for paragraph enters more vertical space than line breaks.
Remember to end a <p>
with a </p>.
<br />
- the tag for line breaks
returns to the following line and resumes there.
There's more to ending the break tag, however.
Read on.
Some elements are simply directives and have no content and are their tags are thus handled differently from elements that have content.
For example, horizontal rules are created using the <hr> tag. The horizontal rule is is an empty element because it provides a simple directive - <insert a horizontal line> - and has no content.
Since an empty element does not require an end tag, but the XHTML standard requires one, the convention for empty element tags is to follow the tag with a blank space and a slash to indicate that the tag both opens and closes this element.
Accordingly, the correct horizontal rule tag would read <hr />.
The same is true for other empty elements
tags block/inline headings lists para/line breaks differences
The <div> element allows you to group a set of elements into one block-level box. The browser will start each <div> element on a new line, but you can specify exactly how each <div> element should behave with presentational rules specific to each <div> element.
Reveal the code on lines 377-387 to see the <div> elements in use here.
The <span> element acts as an inline equivalent of a <div> .
The <span> element is used to set off a section of text from its surrounding text.
or ... set off <span style="color:#F65314">a section of text</span> from its surrounding text.
There are some text elements that are not intended to affect the structure of your web pages, but they do add extra information to the pages - they are known as semantic markup.
Examples include
<em> which allows you to indicate where emphasis should be placed on selected words;
Browsers often display <em> as italics
<blockquote> which which indicates that the block of text is a quotation.
Browsers tend to indent the contents of the <blockquote>
Other examples include
<abbr> for abbreviations
<cite> for marking a citation
<address> to contain contact details for an individual
tags block/inline headings lists para/line breaks differences
Copyright © R.E. Bergquist 2014- | Last Updated on | Powered by w3.css