< font color="red" >
A
< font color="green" >B
< font color="blue" >C
< /font >D
< /font >E
< /font >
This demonstrates the precedence of nested HTML tags. First there is A, which is in red, then we have B which is in green, and finally we have C which is in blue. This is easy to see because each letter comes directly after the < font > tag which defines the color attribute to the red, green, and blue. Next, after the letter C (which is in blue since it comes right after the < font > tag that defines the color attribute as "blue"), we have < /font >. The question is, which < font > opening tag does this < /font > close? Is it in order that it was defined? Will it close the < font > tag that defines the color to be red, or the one that defines it to be green, or is it the one that defines it to be blue?
The first thing to notice is that the three tags that have defined the red, green, and blue tags have not yet been closed. The next thing to note is that HTML tags are always nested. This means that the inner-most tag between the red, green, and blue is the one that is defined last, which is blue. Blue is inside of green, and green is inside of red, which makes red the outer-most tag.
The inner-most tag will get closed first, which is blue. The < /font > that is directly after C will close the blue tag. The next < /font > which is after the letter D will close the next inner-most tag, which is green. Finally, the < /font > that is after the E will close the outer-most tag, which is red.
So looking at the events as they occur, we see something like this:
1. Set font color to Red
2. Write the letter A (written in Red)
3. Set font color to Green
4. Write the letter B (written in Green)
5. Set the color to Blue
6. Write the letter C (written in Blue)
7. Close the Blue tag (color now set to Green)
8. Write the letter D (written in Green)
9. Close the Green tag (color now set to Red)
10. write the letter E (written in Red)
11. Close the Red tag (color now set to default, or back to what it was before the color was set to red at the very start, for example, what it was in the < body text="white" > tag)
From this, you can see how the precedence of nesting is done. The inner-most nested tag has the highest priority and the priority decreases as you go toward the most outer-nested tag.
In the next tutorial, we will talk about a related topic, HTML tag scope.
Published by Kantus
I love writing short stories and humor articles, but tend to stick with topics that are discoverable by search engines and capable of spreading virally. View profile
Photoshop Tutorial: How to Digitally Create Beautiful White TeethLearn how to digitall create beautiful white teeth in photoshop. This is perfect if you're a beginner in photoshop, or if you just want to learn some new techniques. Check out t...
Photoshop Tutorial : How to Apply a Weather Effect to Your Text ?This tutorial will show you how to add a Weather effect to your text , weather snow or any thing you want to add a look like a natural effect .- What Are META Tags?META tags tell the search engines what your website is about and offers a general site description to web users.
- Christmas Cookie Cutter Gift TagsI always buy my nametags for my Christmas gifts each year, but I remember as a child making handmade tags for each gift. It is a great way to personalize your Christmas gifts.
- HTML Tutorial #3 - Basics of Nested Tags
- Photoshop Tutorial: Color Correcting and Tone Enhancing Photographs
- Photoshop Tutorial: Adding Digital Rain to Your Images
- Photoshop Tutorial: Learning How to Use and Load Brushes in Photoshop
- Beginner's Photoshop Tutorial: Learning to Create Your Own Brushes
- Photoshop Tutorial: How to Cut and Put Images on a Transparent Background
- Photoshop Tutorial: How to Change Hair Color in a Photo




1 Comments
Post a Commentthere is no tag