معرفی سایت الکسا برای نشان دادن رتبه و عملکرد سایت شما

سایت الکسا

ایران گستر در صدد آن است تا شما عزیزان را با طراحی سایت با وردپرس آشنا کنیم و سایت الکسا را معرفی کنیم تا بتوانید نتایج آنرا در سایت خود به کار گیرید. که  تمامی این مقالات را به صورت کاملا رایگان در اختیارتان قرار میدهد, پس با ما همراه باشید.







معرفی سایت alexa
رتبه بندی صفحات وب  قبلا توسط گوگل و ابزار page rank آغاز شد که برای رتبه بندی سایت ها و وبلاگ ها و حتی صفحات مختلف هر پایگاه اینترنتی ، امتیازی بین ۰ تا ۱۰ داده می شد و سایت های با رنک بالاتر از مزایایی در موتور جستجوی گوگل برخوردار هستند و به نوعی اعتبار یک سایت یا وبلاگ محسوب میشود.
چند سالی است که سایت alexa.com اقدام به انتشار آمار و ارقامی برای رتبه بندی سایت ها و اخیرا برای وبلاگ ها نموده که قابلیت نمایش رتبه سایت یا وبلاگ شما را در بین کل سایت های موجود در اینترنت و یا در بین سایت های یک کشور را دارا می باشد.
این سایت طی فعالیت های خود توانسته جایگاه مناسبی برایرتبه بندی پایگاه های اینترنتی اخذ و آمار قابل اعتمادی را ارائه دهد که کاربران معمولا برای نشان دادن اعتبار سایت خود ، از آمار خود در الکسا استفاده می کنند.




الکسا یکی از شرکتهای زیر مجموعه ی آمازون به شمار می رود که کار اصلی آن رنکینگ و رتبه بندی وب سایت هاست، سایت الکسا بر اساس میزان ترافیک مصرفی آنها است. به این معنی که متناسب با میزان پهنای باند مصرفی، رتبه سایت را مشخص می کند. رتبه ها از ۱ شروع شده و تا اعدادی حدود ۱۰ میلیون ادامه دارد.
در این سایت برعکس پیج رنک، هرچه عدد پایین تر باشد بهتر است. یعنی رتبه هایی که به یک نزدیکترند سایت هایی با میزان بازدید بیشتری هستند. البته ذکر این نکته لازم است که لزوما ترافیک سایت تابعی از تعداد بازدید نیست اما برای بدست آوردن یک تقریب معیار خوبی است.
سایت الکسا همانند سایتهای گوگل و یاهو دارای یک نوار ابزار مخصوص به خود است که کاربران می توانند با نصب آن، از امکانات سایت الکسا استفاده نمایند. نوار ابزار الکسا را از اینجا بر روی مرورگر خود نصب نمایید.


به مدیران سایت ها و وبلاگ ها پیشنهاد می شود که حتما از این نوار ابزار استفاده نمایند.




آنچه مسلم است ، اطلاعات ارائه شده در الکسا برای رتبه بندی، ۱۰۰درصد دقیق نیست اما این



  • ۰
  • ۰

hair transplant in Itan gives you the chance to regain your confidence and once again enjoy a healthy, full head of natural hair. Today’s methods such as forehead reduction in Iran are much more effective, less painful, and require much less recovery time than in the past. However, there are still things you need to know to ensure a successful hair transplant recovery process.

1. Downtime matters after hair transplant in Iran

First and foremost, make sure you have plenty of downtime. The first 24 hours are very important – you should not do anything during this period. After the first day or more, you can resume some of your normal activities, but your doctor may recommend limiting your strenuous activities for longer periods of time.

2. Avoid exercise and heavy activities

While the first 72 hours of recovery after a “hair transplant in Iran” are most critical, you need to relax for a while. Most doctors recommend that you avoid exercise and other strenuous activities for about two weeks after a hair transplant in Iran.

The point is to increasing blood flow to the scalp too much during this time, so you’ll want to refrain from certain activities and even physical motions, such as:

1.Bend at the waist (bend at the knee instead)

2.Running or jogging

3.Sit up or push up

Any activity that raises blood pressure in the scalp or leads to heavy sweating should be avoided during this period and also after forehead reduction in Iran

Avoid exercise and heavy activities

3. Do not wash yet

You should not wash your hair for the first 72 hours after the hair transplant in Iran. This will give your scalp time to heal. After this period, you can gently wash your hair.

However, do not apply the shampoo directly to your head. Pour a few drops of shampoo into a cup, add water, shake it to mix and lather it up, then pour it over your scalp and then rinse with clean water. In the first week after surgery, keep your head away from direct spray of showerhead.

4. Avoid the headwear hair transplant in Iran

Yes, it is normal to want to wear a hat, but you should avoid it for the first seven days or so. After this time, you can wear a loose hat, but avoid anything that fits tightly. After five days, you can wear any kind of headwear you want.

5. Alcohol and nicotine

Alcohol dilutes the blood, so it is important to avoid it for the first five days or so after surgery. For nicotine, because of the effect of nicotine on blood pressure and reduction of blood flow, you should not smoke for about four weeks before and after this surgery and similar surgeries such as forehead reduction in Iran.

Alcohol and nicotine

6. Scratching / itching and sunlight

Your scalp will itch during the healing process. Do not scratch it. You need to allow the scabs to form and the healing process to proceed naturally.

For this reason, keep your scalp out of direct sunlight for about two weeks after this surgery and forehead reduction in Iran.

Foods to help repair more hair

High-fat, high-protein, high-salt, high-starch foods can cause hair loss (also associated with high dairy intake). Adjusting the consumption of some foods to accelerate hair growth does not mean not consuming them.

The important thing is to maintain moderation in food consumption. We need protein for healthy hair. Moderation only means enjoying steak with vegetables and other sources of protein such as seafood, eggs, chicken and beans and nuts which can be also useful for forehead reduction surgery.
To maintain a balanced diet, you should use protein, fat, salt and sugar in proportion to your body weight. A 75 kg person needs 54 grams of protein per day. The protein in 350 grams of steak is much more than the protein the body needs in a day.

Diet to repair hair transplant in Iran

Overcoming hair loss can simply mean consuming a balanced amount of protein (described above). A proper diet to repair hair or accelerate hair growth should include foods rich in antioxidants and foods rich in iron. Vitamin D and omega-3 fatty acids also help hair growth.
Vitamins A, C and E can be found in fruits and vegetables, as well as blueberries, cherries, mangoes, carrots, squash and peppers.
Red meat and eggs are excellent sources of protein and iron. Other sources of iron include spinach, broccoli, cabbage and lentils. (Iron deficiency or anemia is a common cause of hair loss, especially among women)
Salmon is also an excellent source of protein, vitamin D and omega-3s, which should be included in a proper hair restoration diet. If you cannot get these fatty acids by eating salmon or other fish such as salmon and herring, you should eat avocado or pumpkin seeds.

Diet to repair hair

Swelling and medication

For the first 4 to 5 days, your scalp may feel itchy, but this is because it is healing. You will also experience swelling and pain on the second and third days, which is normal but will subside. You may reduce the pain with anti-inflammatory drugs and ice packs that are placed on your forehead, not the graft site.
Many people need prescribed painkillers in the first two nights after this surgery and forehead reduction in Iran. In addition, you may need to take paracetamol (or Co-dydramol) every 6 hours and / or ibuprofen every 8 hours for the first 24 to 48 hours.

Take your first dose of antibiotics with your evening meal. These medications relieve and control your pain. However, you should avoid aspirin. Your doctor may prescribe additional painkillers for hair transplant and forehead reduction in Iran.

Shock loss hair transplant in Iran

If your hair starts to fall out about 2 to 3 weeks after surgery, do not worry. No need to worry because that’s just your new hair growing and pushing out the grafts.

When can I shave my head after FUE hair transplant?

Natural hair growth is usually noticeable four months after hair transplantation, and most patients experience growth between five and twelve months. After a FUE hair transplant, you may shave your head, but we recommend that you wait 8 to 10 days before doing so. The grafts should be secure at this stage and you should be able to cut your hair short without damaging them or compromising your recovery.

However, there are some key points to consider before making your first post-surgery trip to the barber or hair salon. After healing, the operated sites should not be wet shaved for at least three months. In addition, in the first haircut, you should be careful not to use sharp shaving tools, but rather scissors.

Patients who have had FUE hair transplant can usually have their hair cut short, such as number 1 or 2 cut. This is because FUE hair transplant only leaves some tiny dot scars on the scalp when performed by a skilled and trusted surgeon. These scars are usually less than one-millimeter-long and are difficult to see with the naked eye.

When can I shave my head after FUE hair transplant?

Am I allowed to go to gym after a hair transplant in Iran?

Exercise very soon after hair transplantation may have a negative effect on the result. Sweating, straining and hitting the head are also potential risks of strenuous activity. Sweating makes grafts susceptible to infection. When you apply pressure during exercise, making it more likely for the transplanted grafts to pop out.
That being said, after about two weeks, the newly implanted grafts are fully rooted, meaning you can start exercising after 14 days. However, you should be careful and return to it slowly.

How do I sleep after a hair transplant in Iran?

Because your scalp is sensitive and your hair grafts are delicate, the place where you sleep for the first 7 to 10 days after the hair transplant in Iran is very important. It also takes time for your implanted hair to settle and for the incisions to heal. It also determines how much swelling you will experience.

Although sleeping for a few days after a hair transplant can be challenging, keep in mind that any discomfort will not last long.
For the first few days, you should avoid doing things that prevent new grafts from firmly setting in your scalp, such as tossing and turning or rubbing your new hairline on a pillow. It would be better if you slept upright on your back, in a lifted position about a 45-degree angle. You can also utilize a trip pillow for your neck, as it will back your head and protect the hair grafts.

Washing the head after FUE hair transplant:

There is no need to wash the head in the first 4 days after the FUE hair transplant. However, you can wash the rest of your body from the day after hair transplant and forehead reduction in Iran.
You will start washing your head 4 days after the operation. That is, the next day of the surgery is day 1.
For example, if you were to have surgery on Monday, the first day you would wash your head would be Friday.
After the first washing day, continue washing your head once or twice a day until the scabs are gone and the grafted area is clean. This may take 10-15 days of washing after the first wash.

Washing the head after FUE hair transplant:

First week of washing (starting after 4 days after surgery, between days 4th and 12th after transplantation):

During the first week, just tap on the grafted areas (gentle touching) while washing and shampooing the head. You do not apply any rubbing or massaging. You can wash the donor area as you wish, which means you can also shampoo or massage the donor area.
Without wetting your head beforehand, apply lotion on the grafted area, apply a thick layer of lotion there, then wait for about 10 minutes. It is okay to apply some lotion on the donor areas, but there is no real need for it.
10 minutes later, apply the shampoo on top of the lotioned transplanted areas and perform some gentle tapping to combine the shampoo with the lotion there. Also, you may pour the shampoo over the donor sites
You can immediately start washing your head with lukewarm water and low pressure. Mildness is as important as possible in the first week of head washing. In addition, when washing and shampooing your scalp, tap only on the grafted areas with your fingertips.
After some rinsing, add shampoo once or twice and continue rinsing with water to remove the remnants of the lotion and finally rinse with plenty of water.
You are allowed to touch donor area and your face with a towel and dry it. However, do not touch the grafted areas with a towel and let it dry on its own.

Second week of washing (between the twelfth and twentieth days after transplant):

Everything is just like the first week of washing your head. First, apply the lotion to the grafted area, wait 10 minutes, then apply the shampoo to the lotioned area and to the donor area. Start washing your head with low pressure lukewarm water.
This week, in addition to tapping the grafted areas, you can also start very smooth fingertip rubbing and massaging during the washing process.

Shampoo and rinse 2-3 times with gentle fingertip massaging and rinse profoundly with water at the end. Again, do not use any towel to dry the grafted area this week, leave it dry by itself.
During the 2nd week of the washing, the assembled scabs start to fall and the area becomes cleaner and neater. Once the hair transplant in Iran area becomes clean, you can quit using the lotion and continue with your favorite shampoo to wash your head.

Third week of washing and after (beginning of the twentieth day after transplant):

You can return to your normal washing habits, that is, wash your head as you wish, basically you can return to the same life style that you had been leading before the procedure and also using your favorite shampoo.

In addition, you can perform a massage with your fingertips and hand palms normally while washing your head. Any scabs left at this point, let them alone and they will disappear themselves spontaneously a few days later.

Do not try to remove any scab forcefully with your nails or through strict rubbing after hair transplant in Iran.

  • fateme feysali
  • ۰
  • ۰

LASIK surgery in Iran is often recognized as one of the safest surgical procedures with a low rate of infection and serious complications. In fact, LASIK candidates can be treated with peace of mind because they know that the risks are very few. However, at least for the initial stages of recovery, certain side effects should be expected that require rest and take time for patients to heal. As one of the most common complications of LASIK surgery, light sensitivity can surprise patients if they do not know what to expect during this time.

What causes light sensitivity after LASIK eye surgery in Iran?

If you become sensitive to light in the days after LASIK eye surgery in Iran, it may be due to one or a combination of reasons. Usually, sensitivity is caused by swelling of the corneal tissue in response to the injury caused during the creation of the corneal flap. This flap heals relatively rapidly after surgery and barely lead to complications, but during this time, the recovery process is to make patients hypersensitive to bright lights. At the same time, patients also tend to have dry eyes in the early stages of recovery, further exposing the tissues to discomfort from environmental issues including light.

LASIK methods that use IntraLase or other bladeless lasers to create corneal flaps result in a unique form of light sensitivity called transient light sensitivity (TLS). TLS is often more important than normal light sensitivity and may not appear for several weeks after surgery. However, with timely and appropriate professional treatment, patients can effectively reduce this problem.

causes light sensitivity after LASIK eye surgery

What can be expected from light sensitivity?

Patients who have post-surgery light sensitivity describe it as a feeling of discomfort when exposed to bright light, which forces them to protect their eyes or look away. The light source can be natural or artificial, such as sunlight or an indoor lamp. The severity of the discomfort  LASIK eye surgery in Iran and its situations vary depending on the patient’s individual sensitivity and tolerance. In some cases, patients may need to avoid all light except dim light for the first few days of recovery, while other patients can easily tolerate more light levels without difficulty. Although no patient can necessarily predict their exact side effects, a few basic precautions can help everyone to recover more easily.

Ways to decrease sensitivity

At present, surgical procedures have significantly improved the side effects of treatment. For example, by cooling the cornea after ” LASIK eye surgery in Iran ” and prescribing anesthetic eye drops, an experienced ophthalmologist can reduce the sensitivity in both severity and duration. During recovery, the patient can take further steps to reduce discomfort:

1.Avoid bright lights:

It seems pointless, but avoiding exposure to bright lights can be difficult. Whether walking outdoors or in a bright room, strategic avoidance of such environments requires little planning.

2.Protect your eyes from direct exposure:

If you need to be in a bright area, plan accordingly. Put on sunglasses, a brimmed hat, or both.

3.Avoid monitors:

TV and computer screens are bright and may cause eye strain while your tissues are still healing. Try to avoid such a screen in the first 48 hours of recovery.

4.Contact your doctor if the sensitivity continues:

If your sensitivity to light persists for more than the first week, gets worse, or reappears in the following weeks, call your doctor right away. You may be prescribed anti-inflammatory drugs or alternative therapies to ensure the health of your eyes and corneal tissue. Even if you are not sure that your side effects are normal, it is better to be careful than to suffer from a possible complication.

Ways to decrease sensitivity

Sensitivity to light after Lasik eye surgery in Iran: Is it a side effect or a complication?

Some LASIK patients experience light sensitivity due to dry eyes or due to swelling of the surgical site which causes the glare and halo. If it is the latter, do not worry. The corneal flap heals quickly, and some patients can tolerate the sensitivity without much difficulty.

If you are worried about light sensitivity after LASIK surgery, you can follow some tips. You should keep away bright lights by wearing sunglasses and staying awy from screens. Especially for the latter, try not to use your phone, tablet, laptop or TV for at least two days.

After a week, if you still feel uncomfortable looking at bright lights, you may want to call your doctor, who may prescribe anti-inflammatory eye drops. You should also contact your surgeon as soon as possible if your light sensitivity worsens. It is better to be careful, instead of suffering from a possible complication.

How long do this light sensitivity last?

Generally, light sensitivity issues last for several weeks and the sensitivity decreases with each passing day. Significant light sensitivity problems should be resolved after a week or more, so patients will not notice major discomfort from bright light until then, even if their contrast sensitivity is still affected.

The vast majority of patients will recover by the end of six weeks to two months and will adjust to their new vision, and light sensitivity / perception will often return to normal.

How long do this light sensitivity last?

Tips for dealing with light sensitivity

In the first days after LASIK eye surgery in Iran, it is very important that patients avoid direct sunlight and bright light as much as possible. This helps reduce discomfort and helps the healing process.

Patients are advised to wear sunglasses to reduce light sensitivity problems. It is also a good idea to wear a brimmed hat with sunglasses as it helps blocks too much light from the eyes.

For the first 24 to 48 hours after LASIK, patients should avoid using computers, playing video games, or watching television. All this can cause eye fatigue. Focus on resting your eyes instead to improve and accelerate the healing experience.

Wait before watching TV

Because your eyes are still healing, they will be sensitive in the first 24 hours after LASIK. Therefore, it is recommended to wait at least 24 hours before watching TV again.

Watching TV immediately after surgery can put pressure on your eyes and this negatively affects the healing process. Keeping your eyes away from the screen prevents them from straining, getting tired and drying out. After the first 24 hours, your eyes should be strong enough to handle a bit of screen.

Wait before watching TV

After LASIK eye surgery in Iran, relax while watching TV

Even after 24 hours, you should be comfortable watching TV. Remember, your eyes are still healing after a medical procedure. So do not watch your favorite programs right away. Instead, in the days after surgery, it is a good idea to limit your time in front of the screen.

Try to watch one or two episodes during the day and control the feeling in your eyes. If you notice discomfort or pressure, rest and do something else or close your eyes to let them rest.

What is the distance between rhinoplasty and LASIK eye surgery?

You can also obey the 20-20-20 rule. The 20-20-20 rule says that you should look away from the screen every 20 minutes at something that’s about 20 feet far from for about 20 seconds. This will contribute prevent fatiguing and guarantees proper healing after your LASIK eye surgery in Iran procedure.

What eye conditions can cause light sensitivity?

Many eye conditions can cause light sensitivity and glare, some examples are:

Ocular albinism

This is when some people are born with a pigment deficiency in the eye.

Aneridia

A condition in which the iris is absent from birth.

Macular Degeneration

A condition that affects the macula, the area in the eye that is responsible for our central and accurate vision.

What eye conditions can cause light sensitivity?

Uveitis

Inflammation inside the eye, such as the iritis.

Hereditary retinal dystrophies such as retinitis pigmentosa.

Conditions that affect the anterior surface of the eye, such as conjunctivitis, dry eye, or corneal problems.

If you are starting to experience light sensitivity after LASIK eye surgery in Iran, it is important to see an optometrist (also known as an optician) to check your eyes. An optometrist can check the health of your eyes to check for any underlying eye conditions that could cause light sensitivity.

If you suddenly become sensitive to light or the sensitivity to light gets worse, it should be checked as soon as possible, as it could indicate a worsening or a new condition. Much less common, sudden severe sensitivity to light can be the first sign of a more serious illness such as meningitis, which can cause light to become painful very quickly. If in doubt, it is always best to check for new symptoms with your doctor or optometrist.

Sensitivity to light can be caused simply by eye fatigue or dry eyes or issues such as eye infections, eye injuries or eye structure problems. People with lighter eye color are more sensitive to light because darker eyes contain more pigment to protect against bright light.

It can also be a side effect of some medications or a sign of allergies, hangovers or brain or nervous system disorders. It can also occur with age.

Some causes of this sensitivity may lead to more problems in your eyes or vision if left untreated, while others are so serious that you need to go to the emergency room.

Causes

  1. Dry eyes

signs

1.Sensitivity to light

2.Eyesore

3.Feeling that something is in your eyes

4.Red eyes

5.Itchy eyes

6.Blurred vision

The most usual cause of light sensitivity is dry eyes. Dry eye stimuli include aging and changes in hormone levels. People with conditions such as Sjogren’s syndrome and Parkinson’s disease may have an increased risk of dry eye.

  1. Migraine

signs

1.Sensitivity to light or sound

2.Aura (change in how you feel light and sound)

3.Headache

4.Nausea

5.Vomit

6.Fatigue

7.Tingling or numbness in the body

Another common cause of light sensitivity is migraines. It is a neurological disease that causes moderate to severe headaches. Migraines can occur once in a while or are chronic (occur at least 15 days a month).

Sensitivity to light

  1. Eye fatigue

signs

1.Sensitivity to light

2.Eyesore

3.Blurred vision

4.Tense neck or shoulders

5.Difficulty keeping your eyes open

Eye fatigue occurs when your eyes get tired from overuse. This can be due to fatigue or when you have to focus on one area for a long time, such as while driving or using your computer. Eye strain due to excessive screen time is called digital eye strain.

  1. Blepharitis (inflamed eyelid)

signs

1.Sensitivity to light

2.Red and swollen eyelids

3.Itchy eyelids

4.Dandruff-like scales at the base of your eyelids

5.The abnormal growth of eyelashes or their falling out

6.Feeling that something is in your eyes

Blepharitis, or inflammation of the eyelid, is an irritation of the edge or margin of the eyelid.

  1. Conjunctivitis (pink eye)

signs

1.Sensitivity to light

2.Feeling that something is in your eyes

3.Red eyes

4.Discharge from your eyes that may be watery or pus-filled

5.Eyesore

Conjunctivitis is the inflammation of the conjunctiva that covers the surface of your eye.

 

  1. Keratitis (corneal infection)

signs

1.Sensitivity to light

2.eye redness

3.Eyesore

4.Feeling that something is in your eyes

5.Blurred vision

6.Difficulty opening eyes

Keratitis is an inflammation of the cornea, the transparent layer in front of the eye that covers your pupil and iris. This can be caused by viral or bacterial infections, eye damage, the presence of a foreign object in the eye, and prolonged use of contact lenses.

  1. Corneal abrasion

signs

1.Sensitivity to light

2.Blurred vision

3.Feeling that something is in your eyes

4.Redness

5.Eye discharge

Corneal abrasion is a superficial and painful scratch on your cornea

  1. Scleritis

signs

1.Sensitivity to light

2.Severe eye pain

3.Inflammation of the eye

4.Tearing

5.Deep eye pain that may extend to your face and head

Scleritis is an inflammation of the whites of your eyes after LASIK eye surgery in Iran

  • fateme feysali
  • ۰
  • ۰

HTML

ایران گستر در صدد آن است تا با آموزش های تصویری خود, شما را با به روز ترین زبان های برنامه نویسی آشنا کند تا با یادگیری آنها بتوانبد وارد بازار کار شوید و کسب و کار خود را رونق بخشید. از این پس آموزش های HTML مارا دنبال کنید.

 

 

[caption id="attachment_3063" align="aligncenter" width="255"]HTML HTML[/caption]

عناصر معنایی (Semantics)

Semantics به خودی خود و جدا از دنیای برنامه نویسی، مطالعه ی معنی کلمات و عبارات در یک زبان است و از دروس دانشگاهی بسیاری از رشته های علوم انسانی می باشد. اما در دنیای وب زمانی که می گوییم عناصر Semantic یعنی عناصری که فقط عنصر ظاهری نیستند بلکه معنی خاصی را نیز با خودشان دارند. این معنی از یک طرف برای مرورگر و موتور های جست و جو است و از طرف دیگر برای توسعه دهندگان.(ایران گستر)

عناصر غیر معنایی یا non-semantic مانند <div> و <span> معنا یا اطلاعاتی را در مورد محتوای خود به ما نمی دهند اما عناصر معنایی یا semantic مانند <form> و <table>و <article> مشخص می کنند که چه نوع محتوایی دارند.(ایران گستر)

قبل از ارائه ی HTML5 برای مشخص کردن قسمت های مختلف صفحه از کدهایی مثل <“div id=”nav> یا <“div class=”header> استفاده می کردیم اما امروزه چنین کاری منسوخ شده است (متاسفانه برخی از توسعه دهندگان هنوز هم این کار را می کنند). اجزای مختلف یک صفحه در HTML5 به این شکل است:(ایران گستر)

طرح کلی HTML5

طرح کلی HTML5

بنابراین HTML5 عناصر معنایی جدیدی را برای پایه ریزی این طرح به ما می دهد:(ایران گستر)

  • <article>
  • <aside>
  • <details>
  • <figcaption>
  • <figure>
  • <footer>
  • <header>
  • <main>
  • <mark>
  • <nav>
  • <section>
  • <summary>
  • <time>

 

عنصر <section>

این عنصر وظیفه ی تعریف یک قسمت خاص را در سند شما بر عهده دارد. بر اساس documentation ارائه شده از سمت W3C، این عنصر:(ایران گستر)

A section is a thematic grouping of content, typically with a heading.

یعنی عنصر <section> مجموعه ای از محتوا را که موضوع و مضمون مشابهی دارند در یک قسمت جمع می کند و معمولا یک heading نیز به آن ها می دهد. بنابراین صفحه ی اصلی سایت شما می تواند به <section> های مختلفی مانند مقدمه، محتوا، اطلاعات تماس و … تقسیم شود.(ایران گستر)

مثال:

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

<!DOCTYPE html>

<html>

<body>

 

<section>

  <h1>WWF</h1>

  <p>The World Wide Fund for Nature (WWF) is an international organization working on issues regarding the conservation, research and restoration of the environment, formerly named the World Wildlife Fund. WWF was founded in 1961.</p>

</section>

 

<section>

  <h1>WWF's Panda symbol</h1>

  <p>The Panda has become the symbol of WWF. The well-known panda logo of WWF originated from a panda named Chi Chi that was transferred from the Beijing Zoo to the London Zoo in the same year of the establishment of WWF.</p>

</section>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

عنصر <article>

این عنصر محتوای مستقل و جداگانه ای در صفحه را مشخص می کند. یک <article> باید به خودی خود با معنی باشد به طوری که اگر تمام قسمت های دیگر صفحه را حذف کنیم باز هم آن قسمت به صورت جداگانه قابل خواندن و درک باشد و به هیچ عنوان به قسمت های دیگر وابسته نباشد. نمونه های <article>  عبارت اند از:(ایران گستر)

  • پست هایی که کاربران در یک فروم (انجمن اینترنتی) می گذارند.
  • پست هایی که در وبلاگ ها می گذاریم.
  • مقالات مختلف در سایت های خبری.

به مثال زیر توجه کنید:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

<!DOCTYPE html>

<html>

<body>

 

<article>

  <h1>What Does WWF Do?</h1>

  <p>WWF's mission is to stop the degradation of our planet's natural environment, and build a future in which humans live in harmony with nature.</p>

</article>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

تو در تو سازی <article> در <section>

آیا تو در تو سازی <article> در <section> و یا بالعکس شدنی است؟ <article> مشخص کننده ی مقالات مستقل و جداگانه در صفحه ی ما بود. <section> نیز تعریف کننده ی یک قسمت خاص در صفحه ی ما بود.(ایران گستر)

سوال اینجاست: آیا قانون خاصی برای ترکیب این عناصر معنایی به جز معنی شان وجود دارد؟ پاسخ شما خیر است!

حتما در بعضی از وب سایت های اینترنتی دیده اید که <section>  درون تگ <article>  قرار دارد و <article> نیز دارای تگ های <section> است. همچنین برعکس این موضوع را نیز مشاهده کرده اید. به طور مثال ممکن است در یک خبرگزاری اینترنتی، مقالات ورزشی در یک <article> گذاشته شوند که قسمت (section) ورزشی قرار دارند، و از طرفی همان <article> ممکن است قسمت (section) های فنی داشته باشد. بنابراین تو در تو سازی (nesting) این عناصر بر پایه ی معنای آن ها است.(ایران گستر)

 

عنصر <header>

این عنصر یک header (موضوع) برای کل سند شما و یا یک section در صفحه ی شما تعیین می کند. در واقع باید از <header> به صورت نگه دارنده ی اطلاعاتی مانند موضوع و … استفاده کرد و از آن جایی که می توان چند مقاله در یک صفحه داشت، می توانیم چندین <header> نیز در یک صفحه داشته باشیم.(ایران گستر)

به مثال زیر توجه کنید:

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

<!DOCTYPE html>

<html>

<body>

 

<article>

  <header>

    <h1>What Does WWF Do?</h1>

    <p>WWF's mission:</p>

  </header>

  <p>WWF's mission is to stop the degradation of our planet's natural environment, and build a future in which humans live in harmony with nature.</p>

</article>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

عنصر <footer>

این عنصر برای صفحه ی شما یک footer (قسمت پایینی وب سایت یا یک مقاله که معمولا اطلاعات تکمیلی مانند اطلاعات تماس یا نام نویسنده در آن قرار می گیرد) تعیین می کند. بنابراین <footer> باید اطلاعاتی در مورد عنصر نگه دارنده اش داشته باشد و معمولا شامل این موارد می شود: نام نویسنده، اطلاعات مربوط به کپی رایت، شرایط و قوانین استفاده، اطلاعات تماس و …. . از آنجا که می توان چندین مقاله در یک صفحه داشت، می توانیم چندین <footer> نیز در یک صفحه داشته باشیم.(ایران گستر)

به مثال زیر توجه کنید:

 

1

2

3

4

5

6

7

8

9

10

11

12

<!DOCTYPE html>

<html>

<body>

 

<footer>

  <p>Posted by: Amir Zouerami</p>

  <p>Contact information: <a href="mailto:Zouerami@gmail.com">

  Zouerami@gmail.com</a>.</p>

</footer>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

عنصر <nav>

این عنصر لینک های navigation (مسیریابی – لینک هایی که در بالای سایت هستند مانند «خانه» و «تماس با ما» و …) را در بر می گیرد. نکته ای که باید به آن توجه کنید این است که لازم نیست هر لینکی داخل <nav> قرار بگیرد. <nav> ها تنها برای مجموعه ای از لینک ها هستند که قرار است کاربر را به قسمت خاصی منتقل کنند. مثال:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

<!DOCTYPE html>

<html>

<body>

 

<nav>

  <a href="https://www.roxo.ir/series/html-tutorials/">HTML</a> |

  <a href="https://www.roxo.ir/series/html-tutorials/">CSS</a> |

  <a href="https://www.roxo.ir/series/javascript-tutorials/">JavaScript</a> |

  <a href="https://www.roxo.ir/series/sql-language-tutorial/">MySQL</a>

</nav>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

عنصر <aside>

این عنصر محتوایی را تعیین می کند که در کنار محتوای اصلی قرار می گیرد (مانند sidebar ها – مثلا لیست مقالات پر بازدید که به صورت عمودی در برخی از سایت ها موجود است). محتوای درون <aside> باید با محتوای پیرامونش مرتبط باشد.(ایران گستر)

مثال:

 

1

2

3

4

5

6

7

8

9

10

11

12

13

<!DOCTYPE html>

<html>

<body>

 

<p>My family and I visited The Epcot center this summer.</p>

 

<aside>

  <h4>Epcot Center</h4>

  <p>The Epcot Center is a theme park in Disney World, Florida.</p>

</aside>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

عنصر <figure>

هدف <figure> ارائه ی توضیحات متنی برای یک تصویر است. در HTML5 می توانیم این توضیح متنی را به همراه تصویر مورد نظر در <figure> قرار دهیم. بنابراین درون <figure> یک تگ img و یک تگ <figcaption> قرار دارد که حاوی توضیحات متنی است.(ایران گستر)

مثال:

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

<!DOCTYPE html>

<html>

<body>

 

<h2>Places to Visit</h2>

 

<p>Puglia's most famous sight is the unique conical houses (Trulli) found in the area around Alberobello, a declared UNESCO World Heritage Site.</p>

 

<figure>

  <img src="https://www.w3schools.com/html/pic_trulli.jpg" alt="Trulli" style="width:100%">

  <figcaption dir='rtl'>خانه های Trulli در ایتالیا</figcaption>

</figure>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

چرا عناصر معنایی؟

در نسخه های قبلی HTML مانند HTML4 توسعه دهندگان بر اساس سلیقه ی خود از هر عنصری که می خواستند برای ایجاد هر قسمتی از صفحه که می خواستند استفاده می کردند. این موضوع باعث می شود که موتور های جست و جو نتوانند قسمت های مختلف یک صفحه را تشخیص دهند اما با عناصر HTML5 این کار راحت تر شده است.(ایران گستر)

  • fateme feysali
  • ۰
  • ۰

HTML

ایران گستر در صدد آن است تا با آموزش های تصویری خود, شما را با به روز ترین زبان های برنامه نویسی آشنا کند تا با یادگیری آنها بتوانبد وارد بازار کار شوید و کسب و کار خود را رونق بخشید. از این پس آموزش های HTML مارا دنبال کنید.

 

 

[caption id="attachment_3063" align="aligncenter" width="255"]HTML HTML[/caption]

 

HTML5 چیست؟

برای درک HTML5 بهتر است تاریخچه ای کوتاه از زبان HTML را بدانیم. ما از سال 1991 تا سال 1999 شاهد عرضه ی نسخه های 1 تا 4 از HTML بوده ایم. سپس در سال 2000 کنسرسیوم جهانی وب (W3C) پیشنهاد استفاده از XHTML 1.0 را داد که توسعه دهندگان را مجبور به نوشتن کد های تمیز و دقیق می کرد. این مسئله تا جایی پیش رفت که در سال 2004 کنسرسیوم جهانی وب تصمیم گرفت که دیگر HTML را توسعه ندهد بلکه فقط به XHTML بپردازد.(ایران گستر)

سپس در سال 2004 نهاد و گروهی به نام WHATWG (مخفف Web Hypertext Application Technology Working Group) ایجاد شد که هدفشان توسعه ی HTML به صورت مرتب بود، به نحوی که با نسخه های قدیمی هم سازگاری داشته باشد. این گروه طی سال های 2004 تا 2006 توانست پشتیبانی اکثر شرکت های سازنده ی مرورگرهای اینترنتی مطرح را به دست آورد. سپس در سال 2006 کنسرسیوم جهانی وب اعلام کرد که از WHATWG پشتیبانی می کند.(ایران گستر)

در نهایت در سال 2008 اولین نسخه ی آزمایشی HTML5 منتشر شد. سپس در سال 2012 گروه WHATWG و کنسرسیوم جهانی وب تصمیم گرفتند که از هم جدا شوند چرا که WHATWG میخواست زبان HTML را به صورتی توسعه دهد که مرتبا بروزرسانی و ویرایش شود، و در عین بروزرسانی با قابلیت های قدیمی نیز سازگار باشد. به همین دلیل اولین نسخه ی ارائه شده توسط گروه WHATWG در سال 2012 ارائه شد. از طرفی کنسرسیوم جهانی وب قصد داشت استانداردی مشخص و قطعی برای HTML5 و XHTML بنویسد. بنابراین اولین نسخه ی پیشنهادی HTML5 طبق اعلام کنسرسیوم جهانی وب در 28 اکتبر سال 2014 ارائه شد. متعاقبا HTML5.1 و HTML5.2 نیز به ترتیب در 3 اکتبر 2017 و 14 دسامبر 2017 ارائه شدند.(ایران گستر)

بنابراین همانطور که میدانید HTML5 نسخه ی جدیدتر HTML بوده و در صدد ارتقاء تجربه ی کاربری و کدنویسی افراد در دنیای وب تلاش هایی را انجام داده است. در این مقاله میخواهیم بیشتر با این نسخه از HTML آشنا شویم.(ایران گستر)

 

DOCTYPE مورد نیاز برای تعریف HTML5 بسیار ساده است:

 

1

<!DOCTYPE html>

همچنین تعیین encoding مناسب نیز بسیار راحت شده است:(ایران گستر)

 

1

<meta charset="UTF-8">

البته باید بدانید که encoding پیش فرض در HTML5 همان UTF-8 است.(ایران گستر)

بنابراین یک سند عادی به این شکل خواهد بود:

 

1

2

3

4

5

6

7

8

9

10

11

12

13

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>Page Title</title>

</head>

<body>

 

<h1>This is a Heading</h1>

<p>This is a paragraph.</p>

 

</body>

</html>

در HTML5 عناصر جدیدی نیز معرفی شده اند:(ایران گستر)

  • عناصر معنایی جدید مانند: <header> و <footer> و <article> و <section> و …
  • attribute های جدید برای فرم ها مانند: number و date و time و calendar و range و …
  • عناصر گرافیکی مانند: <svg> و <canvas>
  • عناصر چند رسانه ای جدید: <audio> و <video>

همچنین API جدیدی نیز معرفی شده است که عبارت اند از:(ایران گستر)

  • HTML Geolocation
  • HTML Drag and Drop
  • HTML Local Storage
  • HTML Application Cache
  • HTML Web Workers
  • HTML SSE

بعدا با این موارد آشنا خواهیم شد.

از طرفی عناصر مختلفی نیز منسوخ شدند و شما دیگر نباید از آن ها استفاده کنید:(ایران گستر)

عنصر منسوخ نسخه ی جدید آن
<acronym> <abbr>
<applet> <object>
<basefont> قوانین CSS
<big> قوانین CSS
<center> قوانین CSS
<dir> <ul>
<font> قوانین CSS
<frame>
<frameset>
<noframes>
<strike> قوانین CSS یا <s> یا <del>
<tt> قوانین CSS

 

ناسازگاری مرورگرهای قدیمی

وقتی صحبت از HTML5 میکنیم بسیاری از توسعه دهندگان نگران موضوع عدم سازگاری با تکنولوژی های قدیمی هستند اما شما می توانید به مرورگرهای قدیمی تر بگویید که در مواجهه با HTML5 چکار کنند. همانطور که حدس می زنید، HTML5 در تمام مرورگرهای امروزی پشتیبانی می شود اما در مورد مرورگر های قدیمی تر نکته ی جالبی وجود دارد؛ تمام مرورگرها، چه جدید و چه قدیمی، در برخورد با عنصری که آن را نشناسند، آن را یک عنصر inline در نظر می گیرند. به همین دلیل شما می توانید به مرورگرهای قدیمی یاد بدهید که چطور با عناصر HTML5 که برایشان ناشناخته است کنار بیایند. شما حتی می توانید به IE6 که متعلق به Windows XP 2001 است نیز یاد بدهید که چطور با HTML5 کار کند.(ایران گستر)

HTML5 هشت عنصر معنایی (semantic) جدید را معرفی کرده است که همگی از نوع block هستند. بنابراین برای حل مشکل عدم سازگاری می توانیم دوباره آن ها را در CSS به صورت block تعریف کنیم:(ایران گستر)

 

1

2

3

header, section, footer, aside, nav, main, article, figure {

  display: block;

}

شما همچنین می توانید عناصر جدیدی را در HTML ایجاد کنید. به طور مثال در کد زیر یک عنصر جدید به نام <myHero> را به دلخواه خود ساخته ایم و سپس آن را استایل دهی کرده ایم:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

<!DOCTYPE html>

<html>

<head>

<script>document.createElement("myHero")</script>

<style>

myHero {

  display: block;

  background-color: #dddddd;

  padding: 50px;

  font-size: 30px;

}  

</style>

</head>

<body>

 

<h1>A Heading</h1>

<myHero>My Hero Element</myHero>

 

</body>

</html>

مشاهده ی خروجی در JSBin

کد کوتاه جاوا اسکریپت در مثال بالا (("document.createElement("myHero) برای ایجاد عناصر در مرورگرهای IE 9 و قدیمی تر لازم است.(ایران گستر)

شما می توانید از این راه حل برای تمام مرورگرها استفاده کنید اما متاسفانه مرورگرهای IE8 و نسخه های قدیمی تر آن اجازه ی استایل دهی به عناصر ناشناخته را نمی دهند. خوشبختانه آقای Sjoerd Visscher کد جاوا اسکریپتی به نام HTML5Shiv ساخته است که به مرورگرهایی مانند IE8 و نسخه های قدیمی تر اجازه ی این کار را می دهد.(ایران گستر)

برای استفاده از HTML5Shiv باید آن را در قسمت <head> و درون تگ <script>  قرار دهید. شما می توانید آن را در صفحه ی گیت هاب HTML5Shiv دانلود کنید و یا کد زیر را به مرورگر خود اضافه کنید:(ایران گستر)

 

1

2

3

4

5

<head>

  <!--[if lt IE 9]>

    <script src="/js/html5shiv.js"></script>

  <![endif]-->

</head>

بنابراین یک مثال کامل از HTML5Shiv به این شکل خواهد بود:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<!--[if lt IE 9]>

  <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>

<![endif]-->

</head>

<body>

 

<section>

 

<h1>Famous Cities</h1>

 

<article>

<h2>London</h2>

<p>London is the capital city of England. It is the most populous city in the United Kingdom,

with a metropolitan area of over 13 million inhabitants.</p>

</article>

 

<article>

<h2>Paris</h2>

<p>Paris is the capital and most populous city of France.</p>

</article>

 

<article>

<h2>Tokyo</h2>

<p>Tokyo is the capital of Japan, the center of the Greater Tokyo Area,

and the most populous metropolitan area in the world.</p>

</article>

 

</section>

 

</body>

</html>

مشاهده ی خروجی در JSBin

نکته: تمام این موارد فقط و فقط جهت اطلاع شما گفته شده است. در دنیای واقعی نیازی به این کار نیست؛ توجه کنید که ما (در زمان نگارش این مقاله) در سال 2019 هستیم و به هیچ عنوان نباید نگران سازگاری با مرورگرهای IE8 و غیره باشیم. این مرورگرهای قدیمی خیلی وقت است که از رده خارج شده اند و به توصیه ی تمام محققین و متخصصین باید پشتیبانی از آن ها را رها کرد.(ایران گستر)

  • fateme feysali
  • ۰
  • ۰

HTML

ایران گستر در صدد آن است تا با آموزش های تصویری خود, شما را با به روز ترین زبان های برنامه نویسی آشنا کند تا با یادگیری آنها بتوانبد وارد بازار کار شوید و کسب و کار خود را رونق بخشید. از این پس آموزش های HTML مارا دنبال کنید.

 

 

[caption id="attachment_3063" align="aligncenter" width="255"]HTML HTML[/caption]

ویژگی value

این ویژگی مقدار اولیه ی یک input در فرم ما را مشخص می کند:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

<!DOCTYPE html>

<html>

<body>

 

<h2>The value Attribute</h2>

<p>The value attribute specifies the initial value for an input field:</p>

 

<form action="">

First name:<br>

<input type="text" name="firstname" value="John">

<br>

Last name:<br>

<input type="text" name="lastname">

</form>

 

</body>

</html>

مشاهده ی خروجی در JSBin

ویژگی readonly

این ویژگی باعث می شود که input ما read only شود یعنی هیچکس نتواند آن را تغییر دهد:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

<!DOCTYPE html>

<html>

<body>

 

<h2>The readonly Attribute</h2>

<p>The readonly attribute specifies that the input field is read only (cannot be changed):</p>

 

<form action="">

First name:<br>

<input type="text" name="firstname" value ="John" readonly>

<br>

Last name:<br>

<input type="text" name="lastname">

</form>

 

</body>

</html>

مشاهده ی خروجی در JSBin

ویژگی disabled

این ویژگی باعث می شود که input ما غیرفعال شود. input ای که غیرفعال باشد، غیر قابل کلیک کردن و تغییر دادن است و همچنین مقدار آن در هنگام submit (ارسال نهایی) فرم به سرور ارسال نمی شود:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

<!DOCTYPE html>

<html>

<body>

 

<h2>The disabled Attribute</h2>

<p>The disabled attribute specifies that the input field is disabled:</p>

 

<form action="">

First name:<br>

<input type="text" name="firstname" value ="John" disabled>

<br>

Last name:<br>

<input type="text" name="lastname">

</form>

 

</body>

</html>

مشاهده ی خروجی در JSBin

ویژگی size

این ویژگی سایز یک input را بر اساس تعداد کاراکتر تعیین می کند:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

<!DOCTYPE html>

<html>

<body>

 

<h2>The size Attribute</h2>

<p>The size attribute specifies the size (in characters) of the input field:</p>

 

<form action="">

First name:<br>

 

<input type="text" name="firstname" value="John" size="40">

<br>

Last name:<br>

<input type="text" name="lastname">

</form>

 

</body>

</html>

مشاهده ی خروجی در JSBin

ویژگی maxlength

این ویژگی حداکثر طول مجاز یک input را برای کاربر تعیین می کند:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

<!DOCTYPE html>

<html>

<body>

 

<h2>The maxlength Attribute</h2>

<p>The maxlength attribute specifies the maximum allowed length for the input field:</p>

 

<form action="">

First name:<br>

<input type="text" name="firstname" maxlength="10">

<br>

Last name:<br>

<input type="text" name="lastname">

</form>

 

</body>

</html>

مشاهده ی خروجی در JSBin

به طور مثال اگر مقدار maxlength را 5 بگذارید دیگر فرم اجازه ی تایپ بیشتر از 5 کاراکتر را به کاربر نمی دهد اما توجه داشته باشید که این ویژگی هیچ هشداری به کاربر نمیدهد بنابراین اگر میخواهید پیامی برای کاربر نمایش داده شود و به او بگوید که این فیلد محدود است و یا اینکه چرا این فیلد محدود است باید از کد های جاوا اسکریپت یا روش های دیگر استفاده کنید.(ایران گستر)

هشدار: تمام روش های محدود سازی با HTML (مانند مثال بالا) و Javascript قابل دور زدن هستند و اصلا امن نیستند، بلکه تنها برای راحتی سرور شما و خود کاربران ایجاد شده اند. لازم است که حتما و حتما داده ها را در سمت سرور نیز چک کنید.(ایران گستر)

 

ویژگی autocomplete

این ویژگی می گوید که آیا یک فرم قابلیت autocomplete (تکمیل خودکار) داشته باشد یا خیر. زمانی که autocomplete فعال باشد مرورگر به صورت خودکار مقادیر ورودی را بر اساس مقادیری که کاربر قبلا وارد کرده است پر می کند. autocomplete با عنصر <form> و <input> های متنی، جست و جو، URL، تلفن، ایمیل، رمز عبور، datepicker ها، محدوده و رنگ ها کار می کند.(ایران گستر)

نکته: شما می توانید autocomplete را برای کل فرم (<form>) فعال کرده و سپس برای برخی از input ها غیر فعالش کنید.(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

<!DOCTYPE html>

<html>

<body>

 

<h2>The autocomplete Attribute</h2>

 

<form action="/action_page.php" autocomplete="on">

  First name:<input type="text" name="fname"><br>

  Last name: <input type="text" name="lname"><br>

  E-mail: <input type="email" name="email" autocomplete="off"><br>

  <input type="submit">

</form>

 

<p dir='rtl'>فرم را پر کرده و سپس ارسال کنید. حالا یک بار صفحه را refresh کنید تا ببینید قابلیت تکمیل خودکار چطور کار می کند.</p>

<p dir='rtl'>توجه کنید که قابلیت تکمیل خودکار برای email غیر فعال است.</p>

 

</body>

</html>

مشاهده ی خروجی

برای مشاهده ی خروجی در صفحه مورد نظر کلید Run را بزنید.

 

ویژگی novalidate

این ویژگی میگوید که داده های فرم در هنگام ارسال نباید Validate (اعتبار سنجی) شوند:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

<!DOCTYPE html>

<html>

<body>

 

<h2>The novalidate Attribute</h2>

<p>The novalidate attribute specifies that the form data should not be validated when submitted.</p>

 

<form action="/action_page.php" novalidate>

E-mail: <input type="email" name="user_email">

<input type="submit">

</form>

 

<p dir='rtl'><strong>هشدار:</strong> این قابلیت در مرورگر های internet explorer 9 و نسخه های قبل آن و همچنین در safari 10 و نسخه های قبل آن کار نمی کند.</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

ویژگی autofocus

این ویژگی باعث می شود که پس از بارگذاری صفحه، یکی از input های ما (به انتخاب خودمان) focus بگیرد (یعنی بدون کلیک کاربر فعال شود):(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

<!DOCTYPE html>

<html>

<body>

 

<h2>The autofocus Attribute</h2>

<p>The autofocus attribute specifies that the input field should automatically get focus when the page loads.</p>

 

<form action="/action_page.php">

  First name:<input type="text" name="fname" autofocus><br>

  Last name: <input type="text" name="lname"><br>

  <input type="submit">

</form>

 

<p dir='rtl'><strong>هشدار:</strong>این قابلیت در internet explorer 9 و نسخه های قبل تر آن پشتیبانی نمی شود.</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

پس از ورود به صفحه ی خروجی دکمه ی RUN را بزنید و متوجه خواهید شد که فیلد اول انتخاب شده است و آماده ی تایپ کردن شماست! این همان حالت focus است.(ایران گستر)

 

ویژگی form

این ویژگی مشخص می کند که فلان <input> متعلق به کدام فرم و یا چند فرم است:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

<!DOCTYPE html>

<html>

<body>

 

<h2>The form Attribute</h2>

<p>The form attribute specifies one or more forms an input element belongs to.</p>

 

<form action="/action_page.php" id="form1">

First name: <input type="text" name="fname"><br>

<input type="submit" value="Submit">

</form>

 

<p dir='rtl'>فیلد Last name که در زیر مشاهده می کنید خارج از form بالا است اما هنوز هم به آن تعلق دارد.</p>

Last name: <input type="text" name="lname" form="form1">

 

</body>

</html>

مشاهده ی خروجی در JSBin

نکته: در صورتی که میخواهید یک فیلد را به چند فرم نسبت دهید از ویرگول انگلیسی بین آن ها استفاده کنید.(ایران گستر)

 

ویژگی formaction

این ویژگی مسیر فایلی را مشخص می کند که قرار است فرم ما را پردازش کند. این ویژگی action را باطل می کند و با "type="submit و "type="image استفاده می شود:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

<!DOCTYPE html>

<html>

<body>

 

<h2>The formaction Attribute</h2>

<p>The formaction attribute specifies the URL of a file that will process the input control when the form is submitted.</p>

 

<form action="/action_page.php">

  First name: <input type="text" name="fname"><br>

  Last name: <input type="text" name="lname"><br>

  <input type="submit" value="Submit"><br>

  <input type="submit" formaction="/action_page2.php" value="Submit to another page">

</form>

 

<p dir='rtl'><strong>هشدار:</strong>این قابلیت در internet explorer 9 و نسخه های قبل تر آن پشتیبانی نمی شود.</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

ویژگی formenctype

این ویژگی encoding ارسال فرم را تعیین می کند (فقط برای فرم های “method=”post) و attribute قبلی فرم یعنی enctype را باطل می کند. این ویژگی با "type="submit و "type="image استفاده می شود:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

<!DOCTYPE html>

<html>

<body>

 

<h2>The formenctype Attribute</h2>

<p>The formenctype attribute specifies how the form data should be encoded when submitted (only for forms with method="post").</p>

 

<form action="/action_page_binary.asp" method="post">

  First name: <input type="text" name="fname"><br>

  <input type="submit" value="Submit">

  <input type="submit" formenctype="multipart/form-data" value="Submit as Multipart/form-data">

</form>

 

<p dir='rtl'><strong>هشدار:</strong>این قابلیت در internet explorer 9 و نسخه های قبل تر آن پشتیبانی نمی شود.</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

ویژگی formmethod

این ویژگی متد HTTP برای ارسال فرم ها به action را تعیین می کند و attribute قبلی فرم یعنی method را باطل می کند. این ویژگی با "type="submit و "type="image استفاده می شود:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

<!DOCTYPE html>

<html>

<body>

 

<h2>The formmethod Attribute</h2>

<p>The formmethod attribute defines the HTTP method for sending form-data to the action URL.</p>

 

<form action="/action_page.php" method="get">

  First name: <input type="text" name="fname"><br>

  Last name: <input type="text" name="lname"><br>

  <input type="submit" value="Submit">

  <input type="submit" formmethod="post" value="Submit using POST">

</form>

 

<p dir='rtl'><strong>هشدار:</strong>این قابلیت در internet explorer 9 و نسخه های قبل تر آن پشتیبانی نمی شود.</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

ویژگی formnovalidate

این ویژگی، novalidate را باطل کرده و تغییر میدهد و با  "type="submit استفاده می شود:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

<!DOCTYPE html>

<html>

<body>

 

<h2>The formnovalidate Attribute</h2>

 

<form action="/action_page.php">

  E-mail: <input type="email" name="userid"><br>

  <input type="submit" value="Submit"><br>

  <input type="submit" formnovalidate value="Submit without validation">

</form>

 

<p dir='rtl'><strong>هشدار:</strong>این قابلیت در internet explorer 9 و نسخه های قبل تر آن و همچنین در safari 10 و نسخه های قبل تر آن پشتیبانی نمی شود.</p>

 

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

ویژگی formtarget

این ویژگی مشخص می کند که مرورگر جواب دریافتی از سرور (پس از ارسال فرم) را کجا نمایش دهد. این ویژگی attribute قبلی فرم یعنی target را باطل می کند و این ویژگی با "type="submit و "type="image استفاده می شود:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

<!DOCTYPE html>

<html>

<body>

 

<h2>The formtarget Attribute</h2>

<p>The formtarget attribute specifies a name or a keyword that indicates where to display the response that is received after submitting the form.</p>

 

<form action="/action_page.php">

  First name: <input type="text" name="fname"><br>

  Last name: <input type="text" name="lname"><br>

  <input type="submit" value="Submit as normal">

  <input type="submit" formtarget="_blank" value="Submit to a new window/tab">

</form>

 

 

<p dir='rtl'><strong>هشدار:</strong>این قابلیت در internet explorer 9 و نسخه های قبل تر آن پشتیبانی نمی شود.</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

ویژگی height و width

این دو ویژگی عرض و ارتفاع <"input type="image> را مشخص می کنند:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

<!DOCTYPE html>

<html>

<body>

 

<h2>The height and width Attributes</h2>

<p>The height and width attributes specify the height and width of an input type="image" element.</p>

 

<form action="/action_page.php">

  First name: <input type="text" name="fname"><br>

  Last name: <input type="text" name="lname"><br>

  <input type="image" src="https://www.w3schools.com/html/img_submit.gif" alt="Submit" width="48" height="48">

</form>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

ویژگی list

این ویژگی به <datalist> اشاره می کند که گزینه های از پیش تعریف شده ای برای <input> دارد:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

<!DOCTYPE html>

<html>

<body>

 

<h2>The list Attribute</h2>

<p>The list attribute refers to a datalist element that contains pre-defined options for an input element.</p>

 

<form action="/action_page.php" method="get">

 

<input list="browsers" name="browser">

<datalist id="browsers">

  <option value="Internet Explorer">

  <option value="Firefox">

  <option value="Chrome">

  <option value="Opera">

  <option value="Safari">

</datalist>

<input type="submit">

</form>

 

<p dir='rtl'><strong>هشدار:</strong>

 

این قابلیت در internet explorer 9 و نسخه های قبل تر آن  و همچنین در safari پشتیبانی نمی شود.

 

</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

ویژگی min و max

این دو ویژگی حداقل و حداکثر مقادیر مجاز برای <input> را تعیین می کنند و با input های عددی، محدوده ای، تاریخ، datetime-local، ماه، زمان و هفته کار می کند (اگر با انواع input ها آشنا نیستید به قسمت های قبل از همین سری آموزشی مراجعه کنید):(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

<!DOCTYPE html>

<html>

<body>

 

<h2>The min and max Attributes</h2>

<p>The min and max attributes specify the minimum and maximum values for an input element.</p>

 

<form action="/action_page.php">

 

  Enter a date before 1980-01-01:

  <input type="date" name="bday" max="1979-12-31"><br>

 

  Enter a date after 2000-01-01:

  <input type="date" name="bday" min="2000-01-02"><br>

 

  Quantity (between 1 and 5):

  <input type="number" name="quantity" min="1" max="5"><br>

 

  <input type="submit">

  

</form>

 

<p dir='rtl'><strong>هشدار:</strong>این دو ویژگی در مرورگر Internet Explorer 9 و نسخه های قبل تر آن کار نمی کنند</p>

 

<p dir='rtl'><strong>هشدار:</strong>این دو ویژگی اگر برای تاریخ و زمان به کار بروند در مرورگر Internet explorer 10 کار نمی کنند.</p>

 

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

ویژگی multiple

این ویژگی مشخص می کند که کاربر می تواند بیشتر از یک مقدار را در <input> وارد کند. این ویژگی با <input> های از نوع ایمیل و فایل کار می کند:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

<!DOCTYPE html>

<html>

<body>

 

<h2>The multiple Attributes</h2>

<p>The multiple attribute specifies that the user is allowed to enter more than one value in the input element.</p>

 

<form action="/action_page.php">

  Select images: <input type="file" name="img" multiple>

  <input type="submit">

</form>

 

<p>Try selecting more than one file when browsing for files.</p>

 

 

<p dir='rtl'><strong>هشدار:</strong>این دو ویژگی در مرورگر Internet Explorer 9 و نسخه های قبل تر آن کار نمی کنند</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

ویژگی pattern

این ویژگی از regular expression (عبارات با قاعده) استفاده می کند تا محتوای فرم را چک کند و با انواع input های متنی، جست و جو، URL، تلفن، ایمیل و رمز عبور کار می کند:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

<!DOCTYPE html>

<html>

<body>

 

<h2>The pattern Attribute</h2>

<p>The pattern attribute specifies a regular expression that the input element's value is checked against.</p>

 

<form action="/action_page.php">

  Country code: <input type="text" name="country_code" pattern="[A-Za-z]{3}" title="Three letter country code">

  <input type="submit">

</form>

 

<p dir='rtl'><strong>هشدار:</strong>این قابلیت در internet explorer 9 و نسخه های قبل تر آن و همچنین در safari 10 و نسخه های قبل تر آن پشتیبانی نمی شود.</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

مبحث عبارات با قاعده از مباحث بسیار طولانی در دنیای برنامه نویسی است و نمی شود آن را در این مقاله توضیح داد. اگر با آن ها آشنایی ندارید باید در اینترنت به دنبالشان بگردید و مقالات مختلف در این زمینه را مطالعه کنید.

نکته: برای اینکه به کاربر کمک کنید تا بهتر متوجه الگوی درخواستی بشود از attribute ای به نام title استفاده کنید.(ایران گستر)

 

ویژگی placeholder

این ویژگی متنی کوتاه را در فیلد مورد نظر نشان می دهد تا به کاربر توضیحات خلاصه ای ارائه کند. به طور مثال اگر میخواهید به کاربر بگویید که در این قسمت با حروف انگلیسی تایپ کند می توانید از این ویژگی استفاده کنید. این ویژگی با input های متنی، جست و جو، URL، تلفن، ایمیل و رمز کاربری کار می کند:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

<!DOCTYPE html>

<html>

<body>

 

<h2>The placeholder Attribute</h2>

<p>The placeholder attribute specifies a hint that describes the expected value of an input field (a sample value or a short description of the format).</p>

 

<form action="/action_page.php">

  <input type="text" name="fname" placeholder="First name"><br>

  <input type="text" name="lname" placeholder="Last name"><br>

  <input type="submit" value="Submit">

</form>

 

<p dir='rtl'><strong>هشدار:</strong>این دو ویژگی در مرورگر Internet Explorer 9 و نسخه های قبل تر آن کار نمی کنند</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

ویژگی required

این ویژگی تعیین می کند که فلان فیلد این فرم اجباری است و حتما باید پُر شود و با انواع فیلد های text, search, url, tel, email, password, date pickers, number, checkbox, radio, و file کار می کند.(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

<!DOCTYPE html>

<html>

<body>

 

<h2>The required Attribute</h2>

<p>The required attribute specifies that an input field must be filled out before submitting the form.</p>

 

<form action="/action_page.php">

  Username: <input type="text" name="usrname" required>

  <input type="submit">

</form>

 

<p dir='rtl'><strong>هشدار:</strong>این ویژگی در مرورگر Internet explorer 9 و نسخه های قبل تر آن و همچنین در Safari 10.1 و نسخه های قبل تر آن کار نمی کند.</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

ویژگی step

این ویژگی بازه های مجاز برای یک <input> را تعیین می کنند. به طور مثال اگر این ویژگی برابر با 3 باشد (“step=”3) اعداد مجاز 3- و 0 و 3 و 6 و … خواهند بود. همچنین می توانید از max و min هم به همراه آن استفاده کنید. این ویژگی با فیلد های umber, range, date, datetime-local, month, time و week کار میکند:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

<!DOCTYPE html>

<html>

<body>

 

<h2>The step Attribute</h2>

<p>The step attribute specifies the legal number intervals for an input element.</p>

 

<form action="/action_page.php">

  <input type="number" name="points" step="3">

  <input type="submit">

</form>

 

<p dir='rtl'><strong>هشدار:</strong>این ویژگی در مرورگر Internet explorer 9 و نسخه های قبل تر آن کار نمی کند.</p>

 

</body>

</htmlایران >

مشاهده ی خروجی در JSBin

  • fateme feysali
  • ۰
  • ۰

HTML

ایران گستر در صدد آن است تا با آموزش های تصویری خود, شما را با به روز ترین زبان های برنامه نویسی آشنا کند تا با یادگیری آنها بتوانبد وارد بازار کار شوید و کسب و کار خود را رونق بخشید. از این پس آموزش های HTML مارا دنبال کنید.

 

 

[caption id="attachment_3063" align="aligncenter" width="255"]HTML HTML[/caption]

Input های HTML5

همزمان با معرفی HTML5 انواع مختلفی از input ها نیز به توسعه دهندگان معرفی شد تا بتوانند با استفاده از آن ها برنامه های کاربردی تر و راحت تری بنویسند. آن ها عبارت اند از:(ایران گستر)

  • color
  • date
  • datetime-local
  • email
  • month
  • number
  • range
  • search
  • tel
  • time
  • url
  • week

نکته: از آن جایی که این نوع input ها نسبتا جدید تر هستند ممکن است در تمام مروگر ها کار نکنند. اگر input ای در مرورگری پشتیبانی نشود، به جای آن یک فیلد خالی از نوع <"input type="text> نمایش داده خواهد شد.(ایران گستر)

 

Input های رنگی

این نوع از input ها به صورت <"input type="color> مشخص می شوند و کارشان ایجاد فیلد هایی است که رنگ خاصی را انتخاب کنند. اگر مرورگر کاربر از این input پشتیبانی کند یک color picker برای کاربر نمایش داده خواهد شد:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

<!DOCTYPE html>

<html>

<body>

 

<h2>Color Picker</h2>

<p>The <strong>input type="color"</strong> is used for input fields that should contain a color.</p>

 

<p dir='rtl'>رنگ مورد نظرتان را انتخاب کنید</p>

 

<form dir='rtl' action="/action_page.php">

  <input type="color" name="favcolor" value="#ff0000">

  <input type="submit" value='ارسال رنگ'>

</form>

 

<p dir='rtl'>این قابلیت در internet explorer 11 و safari 9.1 و نسخه های قبلی این دو مرورگر پشتیبانی نمی شود.</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

Input های تاریخ

input های نوع <"input type="date> فیلد هایی مخصوص نگه داری تاریخ می سازند. اگر مرورگر کاربر از آن پشتیبانی کند یک date picker نمایش داده خواهد شد:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

<!DOCTYPE html>

<html>

<body>

 

<h2>Date Field</h2>

<p>The <strong>input type="date"</strong> is used for input fields that should contain a date.</p>

<p>Depending on browser support:<br>A date picker can pop-up when you enter the input field.<p>

 

<form dir='rtl' action="/action_page.php">

  تاریخ تولد:

  <input type="date" name="bday">

  <input type="submit" Value='ارسال فرم'>

</form>

 

<p dir='rtl'>این قابلیت در internet explorer 11 و نسخه های قبلی آن و همچنین در safari پشتیبانی نمی شود.</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

شما همچنین می توانید از attribute های min  و max استفاده کنید تا محدودیت هایی را برای این تاریخ ایجاد کنید:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

<!DOCTYPE html>

<html>

<body>

 

<h2>Date Field Restrictions</h2>

<p>Use the min and max attributes to add restrictions to dates:</p>

 

<form dir='rtl' action="/action_page.php">

تاریخی قبل از سال 1980-01-01 را انتخاب کنید:<br>

<input type="date" name="bday" max="1979-12-31"><br><br>

تاریخی بعد از سال 2000-01-01 را انتخاب کنید:<br>

<input type="date" name="bday" min="2000-01-02"><br><br>

<input type="submit" value='ارسال فرم'>

</form>

 

<p dir='rtl'>این قابلیت در internet explorer 11 و نسخه های قبلی آن و همچنین در safari پشتیبانی نمی شود.</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

Input های Datetime-local

این نوع از input ها با <"input type="datetime-local> مشخص شده و کار آنها دریافت ساعت و تاریخ (بدون هر گونه time zone – منطقه ی زمانی) می باشد:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

<!DOCTYPE html>

<html>

<body>

 

<h2>Local Date Field</h2>

<p>The <strong>input type="datetime-local"</strong> specifies a date and time input field, with no time zone.</p>

<p>Depending on browser support:<br>A date picker can pop-up when you enter the input field.</p>

 

<form action="/action_page.php">

  Birthday (date and time):

  <input type="datetime-local" name="bdaytime">

  <input type="submit" value="Send">

</form>

 

<p dir='rtl'>این قابلیت در internet explorer 12 و نسخه های قبلی آن و همچنین در  safari و firefox پشتیبانی نمی شود.</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

Input های ایمیل

این نوع input ها با <"input type="email> مشخص می شوند و کارشان دریافت ایمیل کاربران است. این نوع input ها معمولا از نظر ظاهری دقیقا شبیه به فیلدهای متنی ساده هستند و تنها تفاوتشان در این است که آدرس ایمیل کاربر را validate می کنند؛ یعنی چک می کنند که آدرس ایمیل نامعتبر نباشد و از الگوی صحیح پیروی کند.(ایران گستر)

همچنین برخی از تلفن های هوشمند می توانند این نوع input را تشخیص دهند و در کیبورد کاربر کلید “com.” را اضافه کنند.(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

<!DOCTYPE html>

<html>

<body>

 

<h2>Email Field</h2>

<p>The <strong>input type="email"</strong> is used for input fields that should contain an e-mail address:</p>

 

<form action="/action_page.php">

  E-mail:

  <input type="email" name="email">

  <input type="submit">

</form>

 

<p dir='rtl'>

<b>هشدار:</b>این قابلیت در Internet Explorer 9 و نسخه های قبل از آن پشتیبانی نمی شود.</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

سعی کنید در خروجی بالا یک ایمیل نا معتبر (مانند example.com یا example یا example.com@me و …) وارد کنید. خواهید دید که فرم ثبت نخواهد شد و به جای آن یک هشدار به شما نمایش داده می شود.(ایران گستر)

 

Input های فایل

کار این نوع input ها که با <"input type="file> مشخص می شوند دریافت فایل های کاربر است. در صورتی که نیاز باشد کاربر فایلی را روی سرور شما آپلود کند (مانند تصویر پروفایل) می توانید از این نوع input استفاده کنید:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

<!DOCTYPE html>

<html>

<body>

 

<h1>File upload</h1>

 

<p>Show a file-select field which allows a file to be chosen for upload:</p>

  <br>

<form dir='rtl' action="/action_page.php">

  یک فایل انتخاب کنید:

  <input type="file" name="myFile"><br><br>

  <input type="submit" Value='ارسال فرم'>

</form>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

Input های ماه

نوع <"input type="month> به کاربر اجازه می دهد که یک ماه و سال را انتخاب کند:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

<!DOCTYPE html>

<html>

<body>

 

<h2>Month Field</h2>

<p>The <strong>input type="month"</strong> allows the user to select a month and year.</p>

<p>Depending on browser support:<br>A date picker can pop-up when you enter the input field.</p>

 

<form action="/action_page.php">

  Birthday (month and year):

  <input type="month" name="bdaymonth">

  <input type="submit">

</form>

 

<p dir='rtl'><strong>هشدار:</strong> این قابلیت در internet explorer 11 و نسخه های قبلی آن و همچنین در safari و firefox پشتیبانی نمی شود.</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

Input های عددی

این نوع input ها که به صورت <"input type="number> مشخص می شوند به کاربر اجازه میدهند که در یک فیلد تنها از اعداد استفاده کند. شما می توانید با min و max حداقل و حداکثر اعداد مجاز را نیز تعیین کنید.(ایران گستر)

در مثال زیر به مرورگر گفته ایم که کاربر حق دارد یک عدد بین 1 و 5 را انتخاب کند:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

<!DOCTYPE html>

<html>

<body>

 

<h2>Number Field</h2>

<p>The <strong>input type="number"</strong> defines a numeric input field.</p>

<p>You can use the min and max attributes to add numeric restrictions in the input field:</p>

 

<form action="/action_page.php">

  Quantity (between 1 and 5):

  <input type="number" name="quantity" min="1" max="5">

  <input type="submit">

</form>

 

<p dir='rtl'><b>هشدار:</b> این قابلیت در internet explorer 9 و نسخه های قبل تر آن پشتیبانی نمی شود.</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

Input های محدوده

این نوع input ها با <"input type="range> مشخص می شوند و کارشان تعیین عددی است که مقدار دقیق آن برای ما مهم نیست (مانند slider ها). حد پیش فرض آن از 0 تا 100 است اما شما می توانید آن را تغییر دهید:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

<!DOCTYPE html>

<html>

<body>

 

<h2>Range Field</h2>

<p>Depending on browser support:<br>The input type "range" can be displayed as a slider control.<p>

 

<form action="/action_page.php" method="get">

  Points:

  <input type="range" name="points" min="0" max="10">

  <input type="submit" value='ارسال فرم'>

</form>

 

<p dir='rtl'>

<b>هشدار:</b>

این قابلیت در internet explorer 9 و نسخه های قبل تر از آن پشتیبانی نمی شود.

</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

Input های جست و جو

این نوع input ها با <"input type="search> مشخص می شوند و فیلدهایی برای قسمت جست و جو در سایت شما هستند:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

<!DOCTYPE html>

<html>

<body>

 

<h2>Search Field</h2>

<p>The <strong>input type="search"</strong> is used for search fields (behaves like a regular text field):</p>

 

<form action="/action_page.php">

  Search Google:

  <input type="search" name="googlesearch">

  <input type="submit">

</form>

 

</body>

</html>

مشاهده ی خروجی در JSBin

این input ها از نظر کارکرد و از نظر ظاهر هیچ تفاوتی با فیلد های متنی ساده ندارند. تفاوت اصلی در بحث semantics و درک موتور های جست و جو از سایت شما است.

 

Input های تلفن

این نوع input ها که با <"input type="tel> مشخص می شوند مسئولیت دریافت شماره تلفن کاربران را دارند:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

<!DOCTYPE html>

<html>

<body>

 

<h2>Telephone Field</h2>

<p>The <strong>input type="tel"</strong> is used for input fields that should contain a telephone number:</p>

 

<form action="/action_page.php">

Telephone: <input type="tel" name="phone" pattern="[0-9]{3}-[0-9]{2}-[0-9]{3}" required>

<input type="submit">

<span>Format: 123-45-678</span>

</form>

 

</body>

</html>

مشاهده ی خروجی در JSBin

احتمالا متوجه قسمت "{pattern="[0-9]{3}-[0-9]{2}-[0-9]{3 نشده اید. از آنجا که هر کشوری الگوی شماره تلفن های مخصوص خودش را دارد شما می توانید این الگو را بر اساس شماره تلفن های کشور خودتان تنظیم کنید. در الگوی بالا گفته شده است {3}[0-9] که یعنی 3 رقم اول شماره تلفن می توانند شامل اعداد 0 تا 9 (همه ی اعداد) بشوند. سپس دو رقم بعدی و در آخر سه رقم بعدی را مشخص کرده ایم. شما می توانید سعی کنید این الگو را مطابق با ایران طراحی کنید.(ایران گستر)

 

Input های زمان

این نوع input ها با <"input type="time> مشخص می شوند و به کاربر اجازه می دهند که بدون ذکر هیچ time zone یا منطقه ی زمانی، یک زمان خاص را انتخاب کند:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

<!DOCTYPE html>

<html>

<body>

 

<h2>Time Field</h2>

<p>The <strong>input type="time"</strong> allows the user to select a time (no time zone):</p>

 

<p>Depending on browser support:<br>A time picker might pop-up when you enter the input field.</p>

 

<form action="/action_page.php">

  Select a time:

  <input type="time" name="usr_time">

  <input type="submit">

</form>

 

<p dir='rtl'>این قابلیت در internet explorer 12 و نسخه های قبل تر آن و همچنین در safari پشتیبانی نمی شود.</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

Input های URL

این نوع input ها به صورت <"input type="url> مشخص می شوند و مسئولیت دریافت یک آدرس اینترنتی (URL) را دارند. برخی از تلفن های هوشمند می توانند این نوع input را تشخیص دهند و در کیبورد کاربر کلید “com.” را اضافه کنند:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

<!DOCTYPE html>

<html>

<body>

 

<h2>URL Field</h2>

<p>The <strong>input type="url"</strong> is used for input fields that should contain a URL address:</p>

 

<form action="/action_page.php">

  Add your homepage:

  <input type="url" name="homepage">

  <input type="submit">

</form>

 

<p dir='rtl'>این قابلیت در internet explorer 9 و نسخه های قبل آن پشتیبانی نمی شود.</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

کار اصلی این نوع فیلد validate کردن داده ی کاربر است؛ یعنی چک می کند تا ببیند آیا آدرس URL ای که کاربر وارد کرده است دارای الگوی صحیحی است یا خیر. می توانید این مورد را در خروجی بالا چک کنید.(ایران گستر)

 

Input های هفته

این نوع input ها به صورت <"input type="week> نوشته می شوند و به کاربر اجازه می دهند تا یک هفته و یک سال را انتخاب کند:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

<!DOCTYPE html>

<html>

<body>

 

<h2>Week Field</h2>

<p>The <strong>input type="week"</strong> allows the user to select a week and year:</p>

<p>Depending on browser support:<br>A date picker can pop-up when you enter the input field.</p>

 

<form action="/action_page.php">

  Select a week:

  <input type="week" name="year_week">

  <input type="submit">

</form>

 

<p dir='rtl'>این قابلیت در internet explorer 11 و نسخه های قبلی آن و همچنین در safari و firefox پشتیبانی نمی شود.</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

  • fateme feysali
  • ۰
  • ۰

HTML

ایران گستر در صدد آن است تا با آموزش های تصویری خود, شما را با به روز ترین زبان های برنامه نویسی آشنا کند تا با یادگیری آنها بتوانبد وارد بازار کار شوید و کسب و کار خود را رونق بخشید. از این پس آموزش های HTML مارا دنبال کنید.

 

 

[caption id="attachment_3063" align="aligncenter" width="255"]HTML HTML[/caption]

 

Input های رایج و قدیمی

همانطور که در دو قسمت قبلی دیدیم، input ها قسمت مهمی از فرم های HTML هستند و ما می خواهیم در این قسمت انواع آن ها را بررسی کنیم. انواع input ها از این قرار هستند:(ایران گستر)

  • <"input type="button>
  • <"input type="checkbox>
  • <"input type="color>
  • <"input type="date>
  • <"input type="datetime-local>
  • <"input type="email>
  • <"input type="file>
  • <"input type="hidden>
  • <"input type="image>
  • <"input type="month>
  • <"input type="number>
  • <"input type="password>
  • <"input type="radio>
  • <"input type="range>
  • <"input type="reset>
  • <"input type="search>
  • <"input type="submit>
  • <"input type="tel>
  • <"input type="text>
  • <"input type="time>
  • <"input type="url>
  • <"input type="week>

ما می خواهیم این موارد را طی دو قسمت بررسی کنیم. در قسمت اول که همین قسمت می باشد، input هایی را به شما معرفی می کنیم که بسیار کاربردی بوده و سال های سال است که مورد استفاده قرار می گیرند. این نوع input ها توسط تمام برنامه نویسان وب شناخته شده هستند و سابقه ای دیرینه دارند. در قسمت بعد به سراغ input هایی خواهیم رفت که در HTML5 معرفی شده اند؛ این input ها تقریبا جدید تر هستند و بعضی از آن ها ممکن است در تمام مرورگر ها پشتیبانی نشوند اما امکانات بیشتری به ما می دهند. پس ابتدا برویم سراغ input های اصلی و رایج(ایران گستر)

 

Input های متنی

<"input type="text> به معنی این است که input ما از نوع متنی بوده و تبدیل به یک فیلد خالی برای تایپ کاربر می شود:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

<!DOCTYPE html>

<html>

<body>

 

<h2>Text field</h2>

<p>The <strong>input type="text"</strong> defines a one-line text input field:</p>

 

<form action="/action_page.php">

First name:<br>

<input type="text" name="firstname">

<br>

Last name:<br>

<input type="text" name="lastname">

<br><br>

<input type="submit">

</form>

 

<p dir='rtl'>توجه داشته باشید که خود تگ form نمایش داده نمی شود.</p>

<p dir='rtl'>عرض پیش فرض هر فیلد 20 کاراکتر است</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

Input های رمز عبور

فیلد های رمز عبور دقیقا مانند فیلد های متنی هستند بنابراین <"input type="password> هنوز هم یک فیلد خالی برای تایپ به ما می دهد اما تفاوت اینجاست که برای حفظ حریم شخصی کاربر، ظاهر هر چیزی که در این قسمت بنویسید با دایره های سیاه جایگزین می شود و کسی نمی تواند رمز تایپ شده ی شما را ببیند:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

<!DOCTYPE html>

<html>

<body>

 

<h2>Password field</h2>

<p>The <strong>input type="password"</strong> defines a password field:</p>

 

<form action="">

User name:<br>

<input type="text" name="userid">

<br>

User password:<br>

<input type="password" name="psw">

</form>

 

<p dir='rtl'>کاراکتر هایی که در input های رمزی تایپ می شوند دیده نمی شوند. می توانید در قسمت راست این موضوع را امتحان کنید.</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

Input های ارسال فرم

<"input type="submit> بدین معنا است که input مورد نظر می خواهد فرمی را ثبت و ارسال (submit) کند. این فرم سپس به یک form-handler ارسال می شود. همانطور که قبلا هم توضیح دادیم form-handler صفحات اسکریپتی در سمت سرور هستند که کار پردازش و ذخیره ی داده های ارسالی را بر عهده دارند و آدرسشان در قسمت action مشخص می شود:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

<!DOCTYPE html>

<html>

<body>

 

<h2>Submit Button</h2>

<p>The <strong>input type="submit"</strong> defines a button for submitting form data to a form-handler:</p>

 

<form action="/action_page.php">

First name:<br>

<input type="text" name="firstname" value="Mickey">

<br>

Last name:<br>

<input type="text" name="lastname" value="Mouse">

<br><br>

<input type="submit" value="Submit">

</form>

 

<p>If you click "Submit", the form-data will be sent to a page called "/action_page.php".</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

نکته: اگر مقدار value را برای submit تعیین نکنید، یک مقدار پیش فرض برای آن تعیین می شود که معمولا همان کلمه ی submit است.(ایران گستر)

 

Input های پاک کردن فرم

input هایی که به صورت <"input type="reset> نوشته می شوند، معمولا یک reset button (دکمه ی ریستارت یا شروع مجدد) را ایجاد می کنند و زمانی که کاربر روی این دکمه کلیک کند تمام محتوایی که در فیلد ها نوشته است پاک می شود.(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

<!DOCTYPE html>

<html>

<body>

 

<h2>Reset Button</h2>

<p>The <strong>input type="reset"</strong> defines a reset button that will reset all form values to their default values:</p>

 

<form action="/action_page.php">

First name:<br>

<input type="text" name="firstname" value="Mickey">

<br>

Last name:<br>

<input type="text" name="lastname" value="Mouse">

<br><br>

<input type="submit" value="Submit">

<input type="reset">

</form>

 

 

<p dir='rtl'>اگر در فیلد های بالا مقداری را بنویسید و تغییرشان دهید، سپس روی دکمه ی reset کلیک کنید تمام محتوای فرم به حالت اولیه ی آن بازمیگردد.</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

Input های radio

در جلسات قبل با radio button ها آشنا شدیم؛ آن ها به هر کاربر اجازه می دهند تا از بین چند گزینه تنها یک گزینه را انتخاب کند:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

<!DOCTYPE html>

<html>

<body>

 

<h2>Radio Buttons</h2>

<p>The <strong>input type="radio"</strong> defines a radio button:</p>

 

<p dir='rtl'>لطفا جنسیت خود را انتخاب کنید:</p>

 

<form dir='rtl' action="/action_page.php">

  <input type="radio" name="gender" value="male" checked> مرد<br>

  <input type="radio" name="gender" value="female"> زن<br>

  <input type="radio" name="gender" value="other"> نمیخواهم اعلام کنم<br><br>

  <input type="submit" Value='ارسال فرم'>

</form>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

Input های Checkbox

input های checkbox به صورت <"input type="checkbox> ساخته می شوند؛ آن ها به کاربر اجازه می دهند که از بین چند گزینه صفر، یک، دو، سه و … یا همه را انتخاب کند:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

<!DOCTYPE html>

<html>

<body>

 

<h2>Checkboxes</h2>

<p>The <strong>input type="checkbox"</strong> defines a checkbox:</p>

  

<p dir='rtl'>مالک کدام موارد هستید؟</p>

 

<form dir='rtl' action="/action_page.php">

<input type="checkbox" name="vehicle1" value="Bike">من دوچرخه دارم

<br>

<input type="checkbox" name="vehicle2" value="Car">من ماشین دارم

<br>

<input type="checkbox" name="bus" value="Car">من اتوبوس دارم

<br><br>

<input type="submit" Value='ارسال فرم'>

</form>

 

</body>

</html>

مشاهده ی خروجی در JSBin

 

Input های دکمه ای

این نوع از input ها به صورت <"input type="button> تعریف می شوند. سوالی که در ابتدا پیش می آید این است که برخی از input های قبلی نیز دکمه می شدند. چرا به این نوع از input ها به طور خاص دکمه ای می گوییم؟ جواب این است که این نوع از input ها تنها یک دکمه هستند و کارکرد آن ها را شما و معمولا با جاوا اسکریپت مشخص می کنید. input های قبلی که تبدیل به یک دکمه شدند کارشان تعریف شده بود و از این نظر با input های دکمه ای متفاوت هستند:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

<!DOCTYPE html>

<html>

<body>

 

<h2>Input Button</h2>

 

<input type="button" onclick="alert('سلام کاربر گرامی!')" value="!روی من کلیک کن">

 

</body>

</html>

مشاهده ی خروجی در JSBin

تا اینجای کار با input های معروف HTML آشنا شدیم. در قسمت بعد به سراغ input هایی خواهیم رفت که در HTML5 معرفی شده اند، یعنی:(ایران گستر)

  • color
  • date
  • datetime-local
  • email
  • month
  • number
  • range
  • search
  • tel
  • time
  • url
  • week
  • fateme feysali
  • ۰
  • ۰

HTML

ایران گستر در صدد آن است تا با آموزش های تصویری خود, شما را با به روز ترین زبان های برنامه نویسی آشنا کند تا با یادگیری آنها بتوانبد وارد بازار کار شوید و کسب و کار خود را رونق بخشید. از این پس آموزش های HTML مارا دنبال کنید.

 

 

[caption id="attachment_3063" align="aligncenter" width="255"]HTML HTML[/caption]

 

عنصر <input>

در جلسه ی قبل به صورت خلاصه اشاره ای به این عنصر داشتیم اما در این قسمت کمی مفصل تر صحبت خواهیم کرد. مهم ترین عنصر یک فرم <input> است که بر اساس مقدار type میتواند به انواع و اشکال مختلفی ظاهر شود:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

<!DOCTYPE html>

<html>

<body>

 

<h2>The input Element</h2>

 

<form action="/action_page.php">

  Enter your name:

  <input name="firstname" type="text">

  <br><br>

  <input type="submit">

</form>

 

</body>

</html>

مشاهده ی خروجی در JSBin

نکته: اگر مقدار type را خالی بگذارید، مقدار پیش فرض که همان text است برایش تعیین می شود.(ایران گستر)

عنصر <select>

این عنصر یک لیستِ drop-down را می سازد. لیست های drop-down لیست هایی هستند که با کلیک روی آن ها می توانید از بین گزینه هایشان که نمایان می شود انتخاب کنید. به مثال زیر توجه کنید:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

<!DOCTYPE html>

<html>

<body>

 

<h2>The select Element</h2>

<p>The select element defines a drop-down list:</p>

 

<form action="/action_page.php">

  <select name="cars">

    <option value="volvo">Volvo</option>

    <option value="saab">Saab</option>

    <option value="fiat">Fiat</option>

    <option value="audi">Audi</option>

  </select>

  <br><br>

  <input type="submit">

</form>

 

</body>

</html>

مشاهده ی خروجی در JSBin

نکته: این خروجی ها تنها برای نمایش ظاهر این عناصر هستند و فاقد قدرت پردازشی می باشند، بنابراین با کلیک روی submit اتفاقی نمی افتد اما در حالت واقعی داده ها پردازش خواهند شد.(ایران گستر)

هر کدام از <option> های بالا یکی از گزینه های لیست ما می باشد و در حالت پیش فرض اولین <option> بدون کلیک و در فیلد ما نمایان خواهد بود. اگر می خواهید این موضوع را تغییر دهید و <option> مورد نظر خود را گزینه ی پیش فرض کنید از selected استفاده کنید:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

<!DOCTYPE html>

<html>

<body>

 

<h2>Pre-selected Option</h2>

<p>You can preselect an option with the selected attribute.</p>

 

<form action="/action_page.php">

  <select name="cars">

    <option value="volvo">Volvo</option>

    <option value="saab">Saab</option>

    <option value="fiat" selected>Fiat</option>

    <option value="audi">Audi</option>

  </select>

  <br><br>

  <input type="submit">

</form>

 

</body>

</html>

مشاهده ی خروجی در JSBin

همچنین اگر می خواهید تعداد گزینه هایی که نمایان هستند افزایش پیدا کنند، می توانید از size استفاده کنید:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

<!DOCTYPE html>

<html>

<body>

 

<h2>Visible Option Values</h2>

<p>Use the size attribute to specify the number of visible values.</p>

 

<form action="/action_page.php">

  <select name="cars" size="3">

    <option value="volvo">Volvo</option>

    <option value="saab">Saab</option>

    <option value="fiat">Fiat</option>

    <option value="audi">Audi</option>

  </select>

  <br><br>

  <input type="submit">

</form>

 

</body>

</html>

مشاهده ی خروجی در JSBin

در آخر اگر می خواهید کاربر بتواند چندین گزینه را انتخاب کند از multiple استفاده می کنید:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

<!DOCTYPE html>

<html>

<body>

 

<h2>Allow Multiple Seletcions</h2>

<p>Use the multiple attribute to allow the user to select more than one value.</p>

 

<form action="/action_page.php">

  <select name="cars" size="4" multiple>

    <option value="volvo">Volvo</option>

    <option value="saab">Saab</option>

    <option value="fiat">Fiat</option>

    <option value="audi">Audi</option>

  </select>

  <br><br>

  <input type="submit">

</form>

 

<p>Hold down the Ctrl (windows) / Command (Mac) button to select multiple options.</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

برای این کار کاربر باید کلید کنترل (Ctrl) را نگه دارد و سپس گزینه های مورد نظرش را انتخاب کنید. بدین ترتیب می توان چندین گزینه را انتخاب نمود. می توانید این مورد را در مثالا بالا امتحان کنید.(ایران گستر)

 

عنصر <textarea>

عنصر <textarea> یک فیلد متنیِ چند خطی را ایجاد می کند. به مثال زیر توجه کنید:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

<!DOCTYPE html>

<html>

<body>

 

<h2>Textarea</h2>

<p>The textarea element defines a multi-line input field.</p>

 

<form action="/action_page.php">

  <textarea name="message" rows="10" cols="30">The cat was playing in the garden.</textarea>

  <br>

  <input type="submit">

</form>

 

</body>

</html>

مشاهده ی خروجی در JSBin

در کد بالا rows مسئول مشخص کردن تعداد خطوط قابل رویت در text area و cols مسئول مشخص کردن عرض قابل رویت آن هستند. البته می توانید این اندازه ها را با CSS نیز تعیین کنید:(ایران گستر)

 

1

2

3

<textarea name="message" style="width:200px; height:600px;">

The cat was playing in the garden.

</textarea>

 

عنصر <button>

عنصر <button> یک دکمه را تعریف می کند:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

<!DOCTYPE html>

<html>

<body>

 

<h2>The button Element</h2>

 

<button type="button" onclick="alert('سلام کاربر گرامی')">روی من کلیک کن</button>

 

</body>

</html>

مشاهده ی خروجی در JSBin

همانطور که می بینید دکمه ها به خودی خود کاری نمی کنند و ما باید برایشان تعریف کنیم که قرار است چه کار کنند.

نکته: مرورگر های مختلف ممکن است از مقادیر مختلفی برای حالت پیش فرضِ type استفاده کنند بنابراین بهتر خودتان آن را مشخص کنید.(ایران گستر)

 

عناصر HTML5

با معرفی HTML5 دو عنصر دیگر نیز به عناصر بالا اضافه شدند:(ایران گستر)

  • <datalist>
  • <output>

این عناصر جدید هستند بنابراین در مرورگر های قدیمی نمایش داده نمی شوند و جای آنها خالی گذاشته می شود.(ایران گستر)

عنصر <datalist> لیستی از گزینه های از پیش تعیین شده را برای <input> ایجاد می کند و کاربران هنگام کار با آن با یک لیست drop-down سر و کار دارند. همچنین list مربوط به <input> باید به id مربوط به <datalist> اشاره کند.(ایران گستر)

مثال:

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

<!DOCTYPE html>

<html>

<body>

 

<h2>The datalist Element</h2>

<p>The datalist element specifies a list of pre-defined options for an input element.</p>

 

<form action="/action_page.php">

  <input list="browsers" name="browser">

  <datalist id="browsers">

    <option value="Internet Explorer">

    <option value="Firefox">

    <option value="Chrome">

    <option value="Opera">

    <option value="Safari">

  </datalist>

  <input type="submit">

</form>

 

<p dir='rtl'><b>هشدار:</b> این قابلیت در مرورگر های سافاری و اینترنت اکسپلورر 9 و قبل تر پشتیبانی نمی شود</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

عنصر <output> نیز نماینده ی یک محاسبه است (معمولا محاسبه هایی که با اسکریپت و در سمت سرور انجام می شوند):(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

<!DOCTYPE html>

<html>

<body>

 

<h2>The output Element</h2>

<p>می توانید مقدار جمع این دو عدد را به راحتی پیدا کنید</p>

 

<form action="/action_page.php"

oninput="x.value=parseInt(a.value)+parseInt(b.value)">

  0

  <input type="range" id="a" name="a" value="50">

  100 +

  <input type="number" id="b" name="b" value="50">

  =

  <output name="x" for="a b"></output>

  <br><br>

  <input type="submit">

</form>

 

<p dir='rtl'><strong>هشدار:</strong> این قابلیت در Edge 12 و IE و مرورگر های قدیمی پشتیبانی نمی شود</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

نکته: این عملیات فعلا کار نمی کند چرا که برای محاسبه ی این اعداد و دریافت خروجی شان نیاز دارید در سمت سرور هم کدهایش را بنویسید.(ایران گستر)

  • fateme feysali
  • ۰
  • ۰

HTML

ایران گستر در صدد آن است تا با آموزش های تصویری خود, شما را با به روز ترین زبان های برنامه نویسی آشنا کند تا با یادگیری آنها بتوانبد وارد بازار کار شوید و کسب و کار خود را رونق بخشید. از این پس آموزش های HTML مارا دنبال کنید.

 

 

[caption id="attachment_3063" align="aligncenter" width="255"]HTML HTML[/caption]

عنصر <form>

عنصر <form> فرمی را تعریف می کند که برای دریافت داده های کاربر مورد استفاده قرار می گیرد و به طور کل به این شکل است:(ایران گستر)

 

1

2

3

4

5

<form>

.

عناصر مختلف فرم در این قسمت نوشته می شوند.

.

</form>

هر فرم HTML ای دارای عناصر فرم (form elements) است و به خودی خود هیچ کاری را نمی تواند انجام دهد. این عناصر فرم در واقع انواع مختلف دریافت داده ها هستند؛ به طور مثال text field (مانند فیلد دریافت نام و نام خانوادگی کاربر)، checkbox (فیلد هایی که کاربر آن ها را تیک می زند) و … . ما می خواهیم با این عناصر به صورت خلاصه آشنا شویم.(ایران گستر)

 

عنصر <input>

عنصر <input> مهم ترین و شناخته شده ترین عنصر یک فرم است. ظاهر این تگ بر اساس attribute ای به نام type تغییر می کند و بستگی دارد که ما به این attribute چه مقداری داده باشیم:(ایران گستر)

Type توضیحات
<input type=”text”> یک فیلد متنی خالی به ما می دهد
<input type=”radio”> یک radio button به ما می دهد (انتخاب یک گزینه بین چند گزینه)
<input type=”submit”> یک submit button به ما می دهد (برای ثبت نهایی و ارسال فرم)

حالت <"input type="text>

نوع text یک فیلد متنی خالی به ما می دهد:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

<!DOCTYPE html>

<html>

<body>

 

<h2>Text Input</h2>

 

<form>

  نام:<br>

  <input type="text" name="firstname">

  <br>

  نام خانوادگی:<br>

  <input type="text" name="lastname">

</form>

 

<p dir='rtl'>توجه داشته باشید که خود تگ form قابل مشاهده نیست.</p>

 

<p>همچنین باید بدانید که عرض پیشفرض این فیلد 20 کاراکتر است</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

نکته: در مورد این فرم باید به دو مورد توجه کرد؛ اولا خود تگ form قابل مشاهده نیست و ثانیا عرض پیشفرض فیلدهای text برابر با 20 کاراکتر است.(ایران گستر)

حالت <"input type="radio>

این نوع از type یک radio button را تعریف می کند. این نوع دکمه ها به کاربر اجازه می دهند که از بین چند گزینه تنها یک گزینه را انتخاب کند. در مثال زیر از کاربر خواسته ایم که جنسیت خود را به ما بگوید:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

<!DOCTYPE html>

<html>

<body>

 

<h2>Radio Buttons</h2>

 

<form>

  <input type="radio" name="gender" value="male" checked> مرد<br>

  <input type="radio" name="gender" value="female"> زن<br>

  <input type="radio" name="gender" value="other"> نمیخواهم اعلام کنم  

</form>

 

</body>

</html>

مشاهده ی خروجی در JSBin

حالت <"input type="submit>

در این نوع type، دکمه ای برای ارسال نهایی فرم به form-handler ایجاد می شود. form-handler ها در اکثر اوقات صفحات اسکریپت نویسی شده ای هستند که اطلاعات کاربر را پردازش می کنند. این صفحات در attribute ای به نام action آدرس دهی می شوند. به مثال زیر نگاه کنید:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

<!DOCTYPE html>

<html>

<body>

 

<h2>HTML Forms</h2>

 

<form action="https://www.w3schools.com/action_page.php">

  First name:<br>

  <input type="text" name="firstname" value="Mickey">

  <br>

  Last name:<br>

  <input type="text" name="lastname" value="Mouse">

  <br><br>

  <input type="submit" value="Submit">

</form>

 

<p dir='rtl'>اگر بر روی دکمه ی submit کلیک کنید اطلاعات فرم به صفحه ی "https://www.w3schools.com/action_page.php" ارسال می شود</p>

 

</body>

</html>

مشاهده ی خروجی در JSBin

پیامی که پس از ثبت فرم به شما نشان داده می شود توسط سرور و پس از بررسی داده ها تولید شده است.(ایران گستر)

 

وظیفه ی action

attribute ای به نام action در تمام فرم ها وجود دارد (به غیر از موارد معدودی که استثناء هستند) و تعیین می کند که پس از ثبت نهایی فرم و ارسال آن چه اتفاقی بیفتد. البته خودِ action کاری انجام نمی دهد بلکه فرم و اطلاعاتش را به صفحه ی اسکریپتی هدایت می کند تا پردازش شود و عکس العملی نشان دهد.(ایران گستر)

در مثال بالا، فرم به صفحه ای به نام action_page.php ارسال شد که شامل اسکریپت های server-side (مانند PHP یا ASP.NET و …) است:(ایران گستر)

 

1

<form action="/action_page.php">

نکته: اگر action را کاملا حذف کنید، فرم به همان صفحه ای که در آن هستید ارسال می شود.(ایران گستر)

 

وظیفه ی target

target تعیین می کند که پس از ارسال فرم، پاسخ در یک سربرگ جدید در مرورگر باز شود، در یک frame دیگر باز شود، در همان صفحه باز شود و الی آخر. مقدار پیش فرض آن self_ است که می گوید فرم در همین پنجره ارسال شود اما اگر می خواهید در یک پنجره ی جدید باز شود باید از blank_ استفاده کنید.(ایران گستر)

مثال:

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

<!DOCTYPE html>

<html>

<body>

 

<h2>The target Attribute</h2>

<p>When submitting this form, the result will be opened in a new browser tab:</p>

 

<form action="https://www.w3schools.com/action_page.php" target="_blank">

  First name:<br>

  <input type="text" name="firstname" value="Mickey">

  <br>

  Last name:<br>

  <input type="text" name="lastname" value="Mouse">

  <br><br>

  <input type="submit" value="Submit">

</form>

 

</body>

</html>

مشاهده ی خروجی در JSBin

مقادیر مجاز دیگر parent_ و top_ و یا نام یک iframe هستند.(ایران گستر)

 

وظیفه ی method

در فرم ها یک attribute بسیار مهم دیگری به نام method (به معنی «روش») وجود دارد. در واقع این attribute روش یا متد ارسال اطلاعات را مشخص می کند که یا می تواند GET باشد و یا POST.(ایران گستر)

مثالی از متد GET:

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

<!DOCTYPE html>

<html>

<body>

 

<h2>The method Attribute</h2>

<p>This form will be submitted using the GET method:</p>

 

<form action="https://www.w3schools.com/action_page.php" target="_blank" method="GET">

  First name:<br>

  <input type="text" name="firstname" value="Mickey">

  <br>

  Last name:<br>

  <input type="text" name="lastname" value="Mouse">

  <br><br>

  <input type="submit" value="Submit">

</form>

 

<p>پس از ثبت فرم به نوار آدرس مرورگر نگاه کنید. اطلاعات ثبت شده را در آنجا می بینید</p>

 

</body>

</html>

مشاهده خروجی در JSBin

مثالی از متد POST:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

<!DOCTYPE html>

<html>

<body>

 

<h2>The method Attribute</h2>

<p>This form will be submitted using the GET method:</p>

 

<form action="https://www.w3schools.com/action_page.php" target="_blank" method="POST">

  First name:<br>

  <input type="text" name="firstname" value="Mickey">

  <br>

  Last name:<br>

  <input type="text" name="lastname" value="Mouse">

  <br><br>

  <input type="submit" value="Submit">

</form>

 

<p>پس از ثبت فرم به نوار آدرس مرورگر نگاه کنید. هیچ اطلاعاتی در آنجا دیده نمی شود</p>

 

</body>

</html>

مشاهده خروجی در JSBin

 

تفاوت GET و POST چیست؟

حالت پیش فرض مرورگر برای ارسال اطلاعات حالت GET است اما زمانی که از GET استفاده می شود تمام اطلاعات ثبت شده در نوار آدرس مرورگر نمایان خواهند بود (رجوع کنید به دو مثال بالا):(ایران گستر)

 

1

/action_page.php?firstname=Mickey&lastname=Mouse

نکاتی در مورد GET:(ایران گستر)

  • داده های فرم را به صورت جفت های name/value در URL قرار می دهد
  • طول این URL محدود است (حدود 3000 کاراکتر)
  • هیچ گاه برای ارسال اطلاعات حساس مانند رمز عبور از GET استفاده نکنید چرا که در نوار آدرس مرورگر قابل مشاهده خواهد بود
  • مناسب برای کاربرانی که می خواهند نتایج را Bookmark کنند
  • GET معمولا مناسب موقعیت هایی است که هیچ اطلاعات حساسی در آن رد و بدل نمی شود، مانند query string های گوگل زمانی که چیزی را در آن سرچ می کنید

اما اگر داده های شما حاوی اطلاعات مهم، شخصی، حساس و … است حتما باید از POST استفاده کنید. این متد داده های شما را در نوار آدرس نشان نمی دهد

نکاتی در مورد POST:

  • POST هیچ محدودیت اندازه ای ندارد و می توانید از طریق آن حجم بزرگی از داده ها را ارسال کنید
  • نتایجی که با POST ارسال شوند قابل bookmark شدن نخواهند بود

 

وظیفه ی name

هر فیلد ورودی (input) باید یک name داشته باشد و اگر فیلدی آن را نداشته باشد، داده های درون آن فیلد اصلا ارسال نمی شوند.(ایران گستر)

در مثال زیر می توانید ببینید که تنها Last name ثبت و ارسال می شود:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

<!DOCTYPE html>

<html>

<body>

 

<h2>The name Attribute</h2>

 

<form action="https://www.w3schools.com/action_page.php">

  First name:<br>

  <input type="text" value="Mickey">

  <br>

  Last name:<br>

  <input type="text" name="lastname" value="Mouse">

  <br><br>

  <input type="submit" value="Submit">

</form>

 

</body>

</html>

جمع کردن داده در فرم ها

عنصر <fieldset> داده های مرتبط با هم را در یک گروه جمع می کند. تگ <legend> نیز توضیحی درباره ی <fieldset> ارائه می کند. به مثال زیر دقت کنید:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

<!DOCTYPE html>

<html>

<body>

 

<h2>Grouping Form Data with Fieldset</h2>

<p>The fieldset element is used to group related data in a form, and the legend element defines a caption for the fieldset element.</p>

 

<form action="/action_page.php">

  <fieldset>

    <legend>Personal information:</legend>

    First name:<br>

    <input type="text" name="firstname" value="Mickey">

    <br>

    Last name:<br>

    <input type="text" name="lastname" value="Mouse">

    <br><br>

    <input type="submit" value="Submit">

  </fieldset>

</form>

 

</body>

</html>

مشاهده خروجی در JSBin

  • fateme feysali
  • ۰
  • ۰

HTML

ایران گستر در صدد آن است تا با آموزش های تصویری خود, شما را با به روز ترین زبان های برنامه نویسی آشنا کند تا با یادگیری آنها بتوانبد وارد بازار کار شوید و کسب و کار خود را رونق بخشید. از این پس آموزش های HTML مارا دنبال کنید.

 

 

[caption id="attachment_3063" align="aligncenter" width="255"]HTML HTML[/caption]

 

 

آشنایی با XHTML

به زبان ساده، XHTML همان HTML است که به صورت XML نوشته شده باشد.(ایران گستر)

 XHTML مخفف EXtensible HyperText Markup Language و به معنی «زبان امتدادپذیر نشانه‌گذاری فرامتنی» است اما نگذارید این اسم های قلمبه و سلمبه شما را فریب دهد! XHTML دقیقا مانند HTML نوشته می شود اما قوانین سخت گیرانه تری دارد و همانطور که گفتیم انگار می خواهیم HTML را به صورت یک برنامه ی XML بنویسیم. همچنین قابل ذکر است که XHTML توسط تمام مرورگر های مطرح پشتیبانی می شود.(ایران گستر)

 

چرا XHTML ؟

بسیاری از صفحات وب دارای HTML بد و غیر معتبر هستند. به طور مثال کد HTML زیر در تمام مرورگر ها کار می کند اما از نظر فنی غیر صحیح است:(ایران گستر)

 

1

2

3

4

5

6

7

8

<html>

<head>

  <title>This is bad HTML</title>

 

<body>

  <h1>Bad HTML

  <p>This is a paragraph

</body>

به نظر شما مشکل کد بالا چیست؟

کد بالا در وهله ی اول هیچ DOCTYPE ای ندارد و مشخص نکرده است که از چه ورژنی از HTML استفاده می کند. همچنین تگ <html> را در آخر سند بسته نشده است و هیچ تگ پایانی را مشاهده نمی کنیم. این اتفاق برای تگ های <head> و <h1> و <p> نیز اتفاق افتاده است.(ایران گستر)

این کد HTML کاملا غیر معتبر و غیر صحیح است اما در اکثر مرورگر های وب بدون مشکل به نمایش در می آید چرا که خود مرورگر ها متوجه اشکالات می شوند و آن ها را در هنگام نمایش تصحیح می کنند. اما این مسئله برای مرورگر های تلفن های همراه اتفاق نمی افتد. معمولا گوشی های هوشمند آنقدر پیشرفته نشده اند که هر نوع خطایی را متوجه شوند و تصحیحش کنند. بنابراین علاوه بر ضربه خوردن از جهت سئو، ممکن است کاربران تلفن های هوشمند نتوانند سایت شما را ببینند و کاربران زیادی را از دست بدهید.(ایران گستر)

از طرفی XML نوعی زبان نشانه گذاری است که در آن باید قوانین نشانه گذاری را به طور کامل رعایت کرد. همانطور که حدس می زنید ترکیب XML و HTML همان XHTML می باشد.(ایران گستر)

 

خصوصیات XHTML

برخی از مهم ترین خصوصیات زبان XHTML از این قرار اند:(ایران گستر)

  • تعریف DOCTYPE در این زبان اجباری است
  • تعریف attribute ای به نام xmlns در <html> اجباری است
  • وجود داشتن تگ های <html> و <head> و <title> و <body> در یک سند اجباری است
  • عناصر XHTML باید به صورت کاملا صحیح nest شوند (تو در تو قرار بگیرند)
  • تمام عناصر XHTML باید همیشه بسته شوند (تگ پایانی)
  • تمام عناصر XHTML باید با حروف کوچک نوشته شوند
  • اسناد XHTML باید حتما یک عنصر root (ریشه ای) داشته باشند
  • نام attribute ها باید همیشه با حروف کوچک نوشته شود
  • مقدار attribute ها باید در Quotation قرار بگیرد
  • خلاصه سازی attribute ها غیر مجاز است.

1- خلاصه سازی attribute ها یعنی مواردی مثل مورد زیر:(ایران گستر)

اگر به جای نوشتن <"option selected="selected> بنویسید <option selected> می گوییم attribute (در اینجا selected) را خلاصه کرده اید.

می خواهیم این موارد را به صورت خلاصه بررسی کنیم.(ایران گستر)

 

اعلام DOCTYPE

یک سند XHTML باید علاوه بر DOCTYPE شامل تگ های <html> و <head> و <title> و <body> باشد.

یک نمونه سند صحیح به این شکل است:(ایران گستر)

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

 

<html xmlns="http://www.w3.org/1999/xhtml">

 

<head>

  <title>Title of document</title>

</head>

 

<body>

  some content

</body>

 

</html>

DOCTYPE ای که در بالا می بینید، نحوه ی اعلام DOCTYPE به عنوان XHTML است.

 

تو در تو بودن (nesting)

در زبان HTML بعضا می توانیم اشتباها عناصر را nest کنیم:(ایران گستر)

 

1

<b><i>This text is bold and italic</b></i>

در این کد تگ های پایانی جا به جا بسته شده اند.

اما در XHTML باید کاملا صحیح nest شوند:

 

1

<b><i>This text is bold and italic</i></b>

 

تگ های پایانی

در HTML این کد غلط است:(ایران گستر)

 

1

2

<p>This is a paragraph

<p>This is another paragraph

و این حالت صحیح است:(ایران گستر)

 

1

2

<p>This is a paragraph</p>

<p>This is another paragraph</p>

حتی تگ هایی که در HTML تگ پایانی ندارند باید در XHTML بسته شوند. در HTML این تگ ها به این صورت هستند:(ایران گستر)

 

1

2

3

A break: <br>

A horizontal rule: <hr>

An image: <img src="happy.gif" alt="Happy face">

اما در XHTML باید به این شکل نوشته شوند:

 

1

2

3

A break: <br />

A horizontal rule: <hr />

An image: <img src="happy.gif" alt="Happy face" />

همچنین همیشه باید تگ هایتان با حروف کوچک باشند بنابراین کد زیر غلط است:(ایران گستر)

 

1

2

3

<BODY>

<P>This is a paragraph</P>

</BODY>

حالت صحیح این کد به این صورت است:(ایران گستر)

 

1

2

3

<body>

<p>This is a paragraph</p>

</body>

 

Attribute ها

کوچک بودن حروف برای attribute ها نیز صدق می کند، بنابراین کد زیر غلط است:(ایران گستر)

 

1

<table WIDTH="100%">

و شکل صحیح آن بدین صورت است:

 

1

<table width="100%">

همچنین باید مقدار این attribute ها در quotation باشد. کد زیر غلط است:(ایران گستر)

 

1

<table width=100%>

و شکل صحیح آن بدین صورت است:

 

1

<table width="100%">

خلاصه سازی attribute ها نیز غیر مجاز است. به نمونه های صحیح و غلط زیر نگاه کنید.(ایران گستر)

کد غلط:

 

1

<input type="checkbox" name="vehicle" value="car" checked />

حالت صحیح آن:(ایران گستر)

 

1

<input type="checkbox" name="vehicle" value="car" checked="checked" />

کد غلط:(ایران گستر)

 

1

<input type="text" name="lastname" disabled />

حالت صحیح آن:(ایران گستر)

 

1

<input type="text" name="lastname" disabled="disabled" />

 

سوال: چطور می توانیم از HTML به XHTML مهاجرت کنیم؟(ایران گستر)

پاسخ: ابتدا باید یک DOCTYPE برای XHTML بنویسید و DOCTYPE قبلی را حذف کنید. سپس attribute ای به نام xmlns را به خودِ عنصر html اضافه کنید. سپس نام تمامی عناصر را با حروف کوچک بنویسید و این کار را با attribute ها نیز انجام دهید. در آخر تگ های خالی (تگ هایی که تگ پایانی ندارند) را ببندید و برای مقادیر attribute ها Quotation قرار دهید.(ایران گستر)

یک مثال از یک سند XHTML برای شما آورده ام:

 

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE html

PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"

"DTD/xhtml1-strict.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<title> Strict DTD XHTML Example </title>

</head>

<body>

<p>

Please Choose a Day:

<br /><br />

<select name="day">

<option selected="selected">Monday</option>

<option>Tuesday</option>

<option>Wednesday</option>

</select>

</p>

</body>

</html>

مشاهده ی خروجی در JSBin

با نگاهی به این سند کوتاه متوجه می شوید که تمام موارد بالا در آن رعایت شده است.(ایران گستر)

  • fateme feysali