Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Inline Styles: An inline style may be used to apply a unique style for a single element.

To use inline
styles, add the style attribute to the relevant element. The style attribute can contain any CSS property.

The example below shows how to change the color and the left margin of a <h1> element: Example <h1
style="color:blue;margin-left:30px;">This is a heading.</h1>

Internal Style Sheet: An internal style sheet may be used if one single page has a unique style.

Internal styles are defined within the <style> element, inside the <head> section of an HTML page:

Example : <!DOCTYPE html> <html> <head> <STYLE TYPE="text/css" MEDIA=screen>


body { background-color: linen; } h1 {
color: maroon; margin-left: 40px; } </STYLE>
</head> <body> <h1>This is a heading</h1> <p>This is a paragraph.</p> </body> </html>

External Style Sheets


External Style sheets are composed of standard text, which consists of a series of entries, each
composed of a selector and a declaration. The selector indicates the HTML element’s affected by the
properties in the declaration.

The external style sheets are saved to a file with an extension .css which can be linked to a web page via
the <LINK> tag.

Syntax:

<LINK REL= stylesheet HREF =”stylesheet file name”>

Example 9: Use of External Style Sheet

Code for mystyle.css


.textChange {
color: red;
font-weight: bold;
}

Code for the HTML page (externals_css.html)


<html>
<head>
<title> Working With External Style Sheet</title>
<LINK REL= stylesheet HREF =”mystyle.css”>
<body>
<p> The <span class="textChange">sun</span> rises in the east </p>
</body>
</html>

Output
JavaScript
JavaScript is an object oriented language that allows creation of interactive web pages.

Advantages of JavaScript:
JavaScript offers several advantages to a web developer.

1. An Interpreted Language: JavaScript is an interpreted language which requires no


compilation steps. The Syntax is completely interpreted by the browser as it interprets HTML
tags.
2. Embedded within HTML: HTML files with embedded JavaScript can be read and
interpreted by any browser which is JavaScript enabled.
3. Minimal Syntax – Easy to learn: Complete applications can be built using JavaScript by
learning just few commands and simple rule of syntax.
4. Quick Development: JavaScript does not require time-consuming compilations; scripts can
be developed in a short period of time.
5. Designed for Simple, small programs: It is well suited to implement simple small programs
and can be easily integrated into a web page.
6. Performance: JavaScript can be written in such that HTML files are fairly compact and
small. These minimize storage requirements on the web server and download time for the client.
7. Procedural Capabilities: JavaScript provides syntax, which can be used to add such
procedural capabilities to web page (filename.html) coding.
8. Designed for Programming User Events: JavaScript supports Object/Event based
Programming. JavaScript can be used to implement context sensitive help. Whenever an HTML
form’s ‘Mouse’ cursor Moves over a button or a link on the page, a helpful and informative
message can be displayed in the status bar at the bottom of the browser window.
9. Easy Debugging and Testing: Being an interpreted language, JavaScript scripts are tested
line by line, the errors also listed as they are encountered. So, it is easy to locate errors , make
changes and test it again without the overhead and delay of compiling.
10. Platform Independence/ Architecture Neutral: JavaScript is a programming language that
is completely independent of the hardware on which it works. JavaScript applications work on
any machine that has an appropriate JavaScript enabled browser installed.
JavaScript interpretation will be with respect to the specific platform. The browser will add
whatever platform specific information is required to the JavaScript while it interprets the code.
Thus, JavaScript is truly platform independent.

JavaScript into HTML


JavaScript syntax is embedded into an HTML file. A browser reads HTML files and interprets
HTML tags. The <SCRIPT> tag informs the browser that specific sections of HTML code are
JavaScript. The browser will then use the built in JavaScript engine to interpret this code.
The <SCRIPT> tag marks the beginning of a snippet of scripting code. The </SCRIPT> tag
marks the end of the snippet of scripting code.

Like HTML tags, the <SCRIPT> tag takes an optional attribute.

Attributes Description
Language Indicates the scripting language used for writing the scripting of snippet
code.

Syntax:
<SCRIPT LANGUAGE=”JavaScript”>
// JavaScript Snippet
</SCRIPT>

You might also like