Blog Intro:
Welcome to our blog post on web programming! In today's digital age, websites have become an integral part of our lives, serving as gateways to information, entertainment, and communication. Behind every successful website lies a powerful web programming language, and one such language is HTML (Hypertext Markup Language). In this article, we will delve into the essential aspects of organizing text, links and URLs, and tables using HTML. Whether you're a seasoned web developer or just starting your journey in the world of programming, this article will provide you with valuable insights to enhance your web development skills. So, let's dive in and uncover the secrets of effective organization in web programming!ORGANIZING TEXT IN HTML:
<!DOCTYPE html> <html> <head> <title>Heading Tags Example</title> </head> <body> <h1>This is a Heading Level 1</h1> <p>Some text goes here...</p> <h2>This is a Heading Level 2</h2> <p>Some more text goes here...</p> <h3>This is a Heading Level 3</h3> <p>Even more text goes here...</p> <h4>This is a Heading Level 4</h4> <p>And more text goes here...</p> <h5>This is a Heading Level 5</h5> <p>Yet another text goes here...</p> <h6>This is a Heading Level 6</h6> <p>Final text goes here...</p> </body> </html>
In this example, we have used six different heading tags (<h1> to <h6>) to create headings of varying levels. The main purpose of heading tags is to define the structure and hierarchy of content on a webpage. The <h1> tag represents the highest level of heading, typically used for the main heading or the title of the page. Subsequent heading tags, such as <h2>, <h3>, and so on, are used for subheadings or sections within the page.
When you view this example in a web browser, you'll notice that the headings are displayed in different sizes, with <h1> being the largest and <h6> being the smallest. This default styling can be modified using CSS (Cascading Style Sheets) to match the design of your website.
Remember, using appropriate heading tags not only helps in organizing and structuring your content but also improves accessibility and SEO (Search Engine Optimization) by providing semantic meaning to the text on your web page.
2) HTML Paragraph:
Example of paragraph tag in html-
<!DOCTYPE html> <html> <head> <title>Paragraph Tag Example</title> </head> <body> <h1>Welcome to My Website!</h1> <p>This is a paragraph of text. It can contain multiple sentences or even just a single sentence. Paragraphs are often used to group related information together and provide a logical flow of content.</p> <p>Here's another paragraph. You can use paragraphs to break up your content and make it more readable. It's a good practice to keep your paragraphs concise and focused on a specific topic.</p> <p>And here's one more paragraph to demonstrate the usage of the paragraph tag. You can include any type of text within a paragraph, including links, images, or other HTML elements.</p> <p>If you need to add additional paragraphs, simply include more <code><p></code> opening and closing tags around your content.</p> </body> </html>
In this example, we have used the `<p>` tags to create paragraphs of text. Each paragraph is enclosed within an opening `<p>` tag and a closing `</p>` tag. You can have as many paragraphs as you need on your webpage.
Paragraph tags are commonly used to structure and format textual content on a webpage. They help separate different blocks of text and make the content more readable and organized. By default, the browser adds some vertical spacing between paragraphs, creating visual separation.
It's important to note that the `<p>` tag is a block-level element, which means it takes up the full width of its parent container. If you need inline text instead of a block, you can use the `<span>` tag or apply CSS styling to achieve the desired result.
3) HTML Division:
Example of division tag in html:
Here's an example of how the division tag (`<div>`) is used in HTML:
<!DOCTYPE html> <html> <head> <title>Division Tag Example</title> <style> .container { background-color: lightgray; padding: 20px; } .box { background-color: white; border: 1px solid black; padding: 10px; margin-bottom: 10px; } </style> </head> <body> <div class="container"> <div class="box"> <h2>Section 1</h2> <p>This is the content of section 1.</p> </div> <div class="box"> <h2>Section 2</h2> <p>This is the content of section 2.</p> </div> <div class="box"> <h2>Section 3</h2> <p>This is the content of section 3.</p> </div> </div> </body> </html>
4) Font:
<!DOCTYPE html> <html> <head> <title>Font Tag Example (Deprecated)</title> </head> <body> <font face="Arial" size="4" color="blue">This is some blue text in Arial font and size 4.</font> <p>However, this paragraph uses the default font and size.</p> <font face="Times New Roman" size="5" color="red">This is some red text in Times New Roman font and size 5.</font> </body> </html>
<!DOCTYPE html> <html> <head> <title>CSS Example</title> <style> .blue-text { font-family: Arial; font-size: 16px; color: blue; } .red-text { font-family: "Times New Roman"; font-size: 20px; color: red; } </style> </head> <body> <p class="blue-text">This is some blue text in Arial font and size 16px.</p> <p>However, this paragraph uses the default font and size.</p> <p class="red-text">This is some red text in Times New Roman font and size 20px.</p> </body> </html>
5) LINKS AND URLS IN HTML:
A link is connection between two web pages. Hyperlinks are HTML links. You can jump to another document by clicking on a link. The mouse arrow will change into a tiny hand when you move the mouse over a link.The href property, which identifies the link's destination, is the most important attribute of the <a> element. The section of the link text that will be visible to the reader is the link text.
The reader will be directed to the given URL address by clicking on the link text.
<a href="url">Link Text</a>
<a href="https://www.example.com">Visit Example Website</a>
<a href="about.html">About</a>
<a href="mailto:info@example.com">Send Email</a>
<a href="#section1">Go to Section 1</a>
https://www.example.com:8080/products/index.html?category=books&page=1#section1
<a href="https://www.example.com">Visit Example Website</a>
<a href="about.html">About</a>
<a href="https://www.example.com"> <img src="image.jpg" alt="Image"> </a>
6) TABLES IN HTML:
HTML tables allow website designers to organise data such as text, photos, links, and other tables into rows and columns of cells. The <table> element is used to build HTML tables, with the <tr> tag used to produce table rows and the <td> tag used to create data cells. By default, the items under <td> are regular and left aligned. The <th> element is used to specify the table heading.<!DOCTYPE html> <html> <head> <title>Table Example</title> <style> table { width: 100%; border-collapse: collapse; } th, td { border: 1px solid black; padding: 8px; text-align: left; } th { background-color: lightgray; } </style> </head> <body> <h1>Employee Directory</h1> <table> <tr> <th>Name</th> <th>Position</th> <th>Department</th> </tr> <tr> <td>John Doe</td> <td>Manager</td> <td>Operations</td> </tr> <tr> <td>Jane Smith</td> <td>Supervisor</td> <td>Human Resources</td> </tr> <tr> <td>Mark Johnson</td> <td>Engineer</td> <td>Research and Development</td> </tr> </table> </body> </html>
6.1 Colspan and Rowspan attributes of <table>
<!DOCTYPE html> <html> <head> <title>Table Example</title> <style> table { width: 100%; border-collapse: collapse; border: 1px solid black; /* Add border to the table */ } th, td { border: 1px solid black; /* Add border to the cells */ padding: 8px; text-align: left; } th { background-color: lightgray; } </style> </head> <body> <table> <tr> <th>Name</th> <th colspan="2">Contact Information</th> </tr> <tr> <td>John Doe</td> <td>john.doe@example.com</td> <td>555-123-4567</td> </tr> </table> </body> </html>
Name | Contact Information | |
---|---|---|
John Doe | john.doe@example.com | 555-123-4567 |
<!DOCTYPE html> <html> <head> <title>Table Example</title> <style> table { width: 100%; border-collapse: collapse; border: 1px solid black; /* Add border to the table */ } th, td { border: 1px solid black; /* Add border to the cells */ padding: 8px; text-align: left; } th { background-color: lightgray; } </style> </head> <body> <table> <tr> <th>Name</th> <th>Contact Information</th> </tr> <tr> <td rowspan="2">John Doe</td> <td>john.doe@example.com</td> </tr> <tr> <td>555-123-4567</td> </tr> </table> </body> </html>
Name | Contact Information |
---|---|
John Doe | john.doe@example.com |
555-123-4567 |