Showing posts with label HTML. Show all posts
Showing posts with label HTML. Show all posts

 

 

Most of ASP.net programmers must have came across writing HTML control by using asp.net. It's not a problem. It can simply be done like this.

 

Response.Write("<input name='cmdTest' type='button' /> ");

 

But the problem comes while writing HTML controls with Javascript function attached and that function has arguments. The problem is due to not allowing of ASP.net to write ["] inside a string, as anything between bracket of Reponse.Write() shoud be purely string. This can be overcomed by just placing a single slash(\) before ("). The following example shows that.

 

Response.Write("<input name='cmdTest' type='button' onclick=\"fn_test('arg1','arg2')\" /> ");

 

 

Here in this example, I have created a simple menu in JavaScript and HTML for Beginners.

I have used two simple <div> elements of HTML and two JavaScript functions to display and hide menu.

The menu is contained in a <Table> element inside a <div>, which is shown and hidden upon entering and leaving of parent <div> element.

The complete source code can be found here.

 
frameset is an element of HTML used to show multiple pages in same window, i.e. each page in a frame.
Element frameset is not supported by XHTML 1.0 Transitional.
But it can be used like this
 
<html xmlns="http://www.w3.org/1999/xhtml">
<
head runat="server">
<title>DAS Reports</title>
</
head>
<
frameset rows="80,* " frameborder="no" border="0" framespacing="0">
<frame src="TopHeader.aspx" name="topFrame" scrolling="no">
<frame src="Login2.aspx" name="centerFrame" scrolling="auto">
</frameset>
</
html>
 
Please note, in above code, there is no body tag.
 

 

A CSS rule consists of two parts:    

  • Selector - the part before the left curly brace    
  • Declaration - the part within the curly braces. It contains Property and values.

 Selector { Property : Value}

 

Eg.   H1 { color: green}

 

An HTML document can have more than one style sheet

associated with it—for example, one internal and one external.

 

To associate a rule with all HTML elements of a specific name, simply use the

tag name. For example, the following rule would apply to all <p>elements in a doc-

ument:

p     { rule details }

To associate a rule with all elements that have a specific classattribute, place a

period before the attribute value:

.value     { rule details }

 

For example, the rule

.emphasize   { rule details }

would apply only to elements where the class="emphasize" attribute is present,

such as either of these:

<p class="emphasize">This text will have the rule

applied.</p>

<td class="emphasize">This table cell will have the rule

applied.</td>

 

 You can combine these two techniques to create a selector that will apply only

to HTML elements with a certain name and a certain value for the class attribute.

Here's how:

ElementName.ClassValue   { rule details }

Here's an example:

p.emphasize   { rule details }

This would apply to the following element:

<p class="emphasize">This text will have the ruleapplied.</p>

It would not apply to either of these elements:

<p>This text will not have the rule applied.</p>

<td class="emphasize">This table cell will not have the rule

applied.</td>

What happens if two style sheet rules conflict? For example, this rule assigns

14-point font to all <p>elements:

p   {font-size: 14pt; }

Here's a rule that assigns 20-point font to all elements where the class attribute

is equal to large:

 

.large   {font-size: 20pt; }

What happens, then, to an HTML element such as this one?

<p class="large">This is the text.</p>

The answer lies in the order of the rules and inheritance—a rule later in the

style sheet takes precedence over rules that come before it. You can override this by

including the !important clause to the rule. Here's an example:

.large   {font-size: 20pt !important;}

 

This ensures that the rule takes precedence over any competing rules even if

they come after in the style sheet. This is not a recommended practice; it's much bet-

ter to lay out the rules in the correct order the first time.

You can assign a single style rule to multiple selectors by separating the selec-

tors with commas. For example, the following selector would assign the rule to <p>

elements that had either emphasizeor strongas the value of the classattribute:

p.emphasize, p.strong   { rule details }

The final selector is for the id attribute of HTML tags. You do this with the #

symbol. For example, the selector

#mainTable   { rule details }

would be applied to the content of any HTML tag that has its id attribute set to

"mainTable", as in this example:

<table width="100%" id="mainTable">

...

</table>

The idattribute differs from the class attribute in that idmust be unique in the

document. In other words, there can be only one tag with a given idvalue. In prac-

tice, browsers do not enforce this rule, but having multiple tags with the same id

value in one page is invalid HTML and not a good idea.

 

Defining CSS Styles

 

CSS formatting uses a simple box-oriented formatting model. Every formatted

element—text or image—will result in one or more rectangular boxes. Each box

has a central content area that is surrounded by optional padding, border, and mar-

gin areas. These boxes are usually not visible, but you need to understand their uses

and relationships in order to work effectively with style sheets. The various boxes are related as follows:

• The innermost box, the content area, is where the data is displayed. This can

be text or an image. For text, the display is controlled by font and text proper-

ties in the style rule. For an image, the size is controlled by the height and

width properties in the style rule. The height and width properties can be used

with text elements also.

• The padding area provides a space between the content and its border. The size

of this area is controlled by the padding properties in the style rule. The back-

ground of the padding area is the same as the background of the content area,

as controlled by the background property.

• The border is an optional box drawn around the element. Its appearance is

controlled by the border properties.

• The margin provides space around the element, outside the border. In effect,

the margin provides the spacing between the element and other elements that

are being displayed. The margin size is controlled by the margin properties.

The margin is always transparent.

 

 
CSS or Cascading Style Sheets as the name suggests is a style sheet that allows you to easily link to other documents in your website. It allows you to retain control over the various elements in different web pages of your website.
 
CSS only defines the structure and content presentation of a website it has nothing to do with the design of a website. A single CSS sheet can control the font, positioning, colour and style information of an entire website.
 
Here, are some of its importances.
 

* Web pages are easier to load and uses less bandwidth

CSS style sheets are preferred by web developers for website development because they are lighter than table layouts, which consumes lots of bandwidth. The style sheet is downloaded only once and stored in the cache memory, so subsequent pages load faster.

* A CSS style sheet compliments well with HTML

HTML is insufficient when used independently in website development, but when combined with CSS they can result in technically stronger web pages.

* CSS allows you to position your element anywhere in the webpage

Web developers love to use CSS because it allows them to position their element where ever they want in the web page. If during any phase of web development the developer feels that particular links or columns are not going well with the situation then it becomes easier for them to position them easily using CSS. CSS reduces the risks associated with maintenance of the website.

* CSS is compatible with all web browsers

CSS is combined with HTML or XHTML by web developers for web application development because it is compatible with all web browsers. The sites that use CSS appear similar in all the web browsers.

* CSS can be used to create print friendly web pages

Most of the web developers love to use CSS for building their HTML based web applications because they allow them to create print friendly web pages. These web pages can be easily printed. The colours, images and other things which are difficult to be printed can be eliminated and printed easily.

* CSS style sheets allows the user to customize the webpage

Now days many websites allow the user to change the layout of the website without affecting the content. The CSS style sheets which are stored externally allow the user to make requisite changes by themselves. Most of the modern browsers give user the liberty to define their own style sheets like changing some font properties etc.

* CSS style sheets makes it easier for your website to feature in search engines

The CSS style sheets are favoured by web developers because they allow them to position their elements as per their wish anywhere in web application. Positioning helps to project the main contents first, so that it is easily captured by web spiders. CSS also gives cleaner HTML codes thus cutting down the job of web spider to search the real content from junk code.
 

 
The select box can be placed in web page by using following code.
 
<FORM name="formMain">
<SELECT name="selData">
<OPTION SELECTED value="data1">mydata1
<OPTION value="data2">mydata2
</SELECT>
</FORM>

The select box can be accessed from JavaScript as follows.
 
To get no. of items in the select box
document.formMain.selData.length
 
To find whether an option in select box is selected or not
document.formMain.selData.options[0].selected
 
To get the value attribute of first option
document.formMain.selData.options[0].value
 
To get the index of selected item in select box
document.formMain.selData.selectedIndex
 
To get the value of selected Item
document.formMain.selData.options[document.formMain.selData.selectedIndex].value
 
Note: JavaScript is case sensitive.
 

Meta tags are descriptive tags placed between <HEAD> and </HEAD> tags of a web page usually the description first and then the keywords metatag.
 
They look like this
 
Description Meta:

<META NAME="description" content="Your most important keyword phrases should appear in this description.">
 
Keywords Meta:
<META NAME="keywords" content="keywords phrase 1, keyword phrase 2, keyword phrase 3, etc.">
Do not repeat keywords more than 2-3 times in these tags otherwise it is considered as spaming.
Your Keywords Meta should not exceed 1024 characters including spaces.
Also your Description Meta tag should not exceed 250 characters including spaces.
You can use plurals and misspelt words within the keywords tags.
The keywords in them should also be found within the content of your website.
 
There is one more meta robots tag.
The Robots META Tag is meant to provide users who cannot upload or control the /robots.txt file at their websites
<meta content='index,follow' name='robots'/>
 
This instructs the search engine spiders to follow all the links and index the site.
If you want it to be a private blog put NOINDEX, NOFOLLOW instead.
 

<input name="Browse" type="file" value="Browse" size="60">



http:// & https://

The main difference between http:// and https:// is, It's all about keeping you secure

HTTP stands for HyperText Transport Protocol, which is just a fancy way of saying it's a protocol (a language, in a manner of speaking) for information to be passed back and forth between web servers and clients.

The important thing is the letter S which makes the difference between HTTP and HTTPS.

The S (big surprise) stands for "Secure".


If you visit a website or webpage, and look at the address in the web browser, it will likely begin with the following: http://.

This means that the website is talking to your browser using the regular 'unsecure' language.

In other words, it is possible for someone to "eavesdrop" on your computer's conversation with the website.

If you fill out a form on the website, someone might see the information you send to that site.

This is why you never ever ever enter your credit card number in an http website!

But if the web address begins with https://, that basically means your computer is talking to the website in a secure code that no one can eavesdrop on.

You understand why this is so important, right?

If a website ever asks you to enter your credit card information, you should automatically look to see if the web address begins with https://.

If it doesn't, there's no way you're going to enter sensitive information like a credit card number!