1. HTML Elements 




HTML elements are written with a start tag, with an end tag, with the content in between:
<tagname>contents</tagname>
The HTML element is everything from the start tag to the end tag:
<p>My first  paragraph.</p
HTML elements can be nested (elements can contain elements).All HTML documents consist of nested HTML elements.
This example contains 4 HTML elements:
Example

<!DOCTYPE html><html><body>   <h1>My First Heading</h1>  <p>My first paragraph.</p></body>
</html>


  • The <body> element defines the document body.
  • It has a start tag <body> and an end tag </body>.
  • The element content is two other HTML elements (<h1> and <p>).
  • he <h1> element defines a heading.
  • It has a start tag <h1> and an end tag </h1>.
  • The element content is: My First Heading.
  • The <p> element defines a paragraph.
  • It has a start tag <p> and an end tag </p>.
  • The element content is: My first paragraph.
  • <p>My first paragraph.</p>
2 .HTML Attributes

  Attributes provide additional information about HTML elements.

HTML Attributes

  • HTML elements can have attributes
  • Attributes provide additional information about an element
  • Attributes are always specified in the start tag
  • Attributes come in name/value pairs like: name="value"

The lang Attribute

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

Example

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

<h1>My First Heading</h1>

<p>My first paragraph.</p>

</body>
</html>

The first two letters specify the language (en). If there is a dialect, use two more letters (US).

Example

<p title="About W3Schools">
W3Schools is a web developer's site.
It provides tutorials and references covering
many aspects of web programming,
including HTML, CSS, JavaScript, XML, SQL, PHP, ASP, etc.
</p>

The href Attribute

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

Example

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

Size Attributes

HTML images are defined with the <img> tag.
The filename of the source (src), and the size of the image (width and height) are all provided as attributes:

Example

<img src="w3schools.jpg" width="104" height="142">

0 comments:

Post a Comment

 
Top