Pankaj Shah web agency director in London with over 20 years of experience in web design and project management

I hope you enjoy reading our blog posts.

If you want DCP to build you an awesome website, click here.

HTML5 & CSS3 – Beginners Tutorial – Part 18 – [ CSS DIV Tag Tutorial ]

This tutorial introduces beginners to the concept of DIV tags in HTML5 and CSS3, explaining their purpose, how to implement them, and their advantages in web design. It covers practical examples, including how to manipulate content using classes and styles, and emphasises the importance of separating content from style for efficient web design.

Welcome to this DCP Web HTML5 and CSS3 beginners tutorial. In this part, we will explore the concept of DIV tags, which are essential for structuring web content effectively.

DIV tags, short for division tags, are used in HTML to divide content into sections. This allows for better organisation and styling of web pages. To get started, open your Notepad++ file where you have your previous content saved. If you see a blank document, simply drag and drop your index file into Notepad++ to access your HTML content.

Setting Up Your Workspace

  1. Open Notepad++: Ensure you have both your HTML and CSS files open side by side in Notepad++.
  2. Open Your Web Browser: Drag your HTML file into the browser to view your current webpage.

Creating a Basic DIV Tag

To illustrate the use of DIV tags, let’s create a simple example. Type the following in your HTML file:

    
     <div>
    <!-- Content goes here -->
</div>

    
   

This DIV tag acts as a container for any content you want to include. It’s important to remember to close your DIV tag to maintain proper HTML structure.

Highlighting Tags in Notepad++

When you click on a DIV tag in Notepad++, it highlights the corresponding closing tag, which is useful for ensuring your tags are properly nested and closed.

Applying Classes to DIV Tags

After creating a DIV tag, you can apply CSS classes to style the content within. For example, if you have a class called intro-text, you can apply it to your DIV tag as follows:

    
     <div class="intro-text">
    <p>Your content here.</p>
</div>

    
   

When you refresh your webpage, the content inside the DIV will inherit the styles defined in the intro-text class.

Manipulating Content with DIV Tags

Suppose your client requests changes to the text colors of different paragraphs. Instead of applying styles directly to each paragraph, you can use DIV tags to group them.

For instance:

  1. Remove individual classes from paragraphs.
  2. Surround the paragraphs with a single DIV tag that has the desired class.

This way, you can manage the styles of multiple paragraphs with just one DIV tag.

Adding Additional Content

You can also add more content within your DIV tags. For example, if you want to include a third paragraph:

    
     <div class="additional-text">
    <p>This is an additional paragraph.</p>
</div>

    
   

You can style this additional paragraph differently by assigning it a separate class.

Styling with CSS

To style your DIV tags, you can define properties in your CSS file. For example:

    
     .intro-text {
    color: red;
    font-size: 150%;
}
.additional-text {
    color: blue;
    font-size: 125%;
    background-color: green;
    width: 50%;
}


    
   

This CSS will apply the specified styles to the respective DIV tags, allowing for a clear visual distinction between different sections of content.

The Importance of DIV Tags

Using DIV tags effectively allows for better organisation of your HTML content. They serve as containers that can hold various elements, making it easier to apply styles and manage layout. For instance, you can create complex layouts with multiple columns by using multiple DIV tags with specific widths.

Recap of Key Points

  • DIV tags are essential for dividing content into manageable sections.
  • Classes can be applied to DIV tags to style multiple elements at once.
  • Proper use of DIV tags simplifies the process of making global changes to your website’s design.
  • CSS allows you to separate content from style, making it easier to maintain and update your website.

Conclusion

In this tutorial, we covered the basics of using DIV tags in HTML5 and CSS3. Understanding how to manipulate content with DIV tags is crucial for building well-structured and visually appealing web pages. As you progress in your web development journey, these concepts will become increasingly important, especially when working on larger websites with multiple pages.

Thank you for following along, and I look forward to seeing you in the next DCP web tutorial!

Author

Picture of Pankaj Shah

Pankaj Shah

Pankaj Shah is the founder of DCP Web Designers, an award-winning London-based web design and digital marketing agency. With over 20 years of experience, he specialises in WordPress web design, WooCommerce, SEO and helping businesses build effective online solutions.
Tell Us Your Thoughts

This website (dcpweb.co.uk) uses cookies to improve your browsing experience and help us understand how our site is used. By continuing to browse this website, you agree to our use of cookies.

To learn more about how we collect, use, and protect your data, please read our Privacy Policy.

Since 2004, we have designed and developed websites for companies across a wide range of industries, from local service businesses to ecommerce brands and professional organisations.

Our focus is on creating websites that not only look professional, but also perform well in search engines, attract the right audience and support long-term business growth.

If you are looking for experienced web designers who understand how to build websites that deliver real results, our team is here to help.

Privacy Policy

Last Updated: 01/07/2024

Different Colour Productions Ltd (“we,” “us,” or “our”) is committed to protecting your privacy. This Privacy Policy outlines our practices concerning the collection, use, and disclosure of personal information when you visit our website or engage with our services. By using our website and services, you consent to the terms outlined in this Privacy Policy.

1. Information We Collect

We collect various types of information to provide and improve our services. The types of information we may collect include:

1.1. Personal Information: This may include your name, email address, phone number, and any other information you provide when you contact us, request information, or subscribe to our newsletter.

1.2. Log Data: When you visit our website, we automatically collect information, such as your IP address, browser type, pages visited, and the time and date of your visit.

1.3. Cookies and Similar Technologies: We use cookies and other tracking technologies to improve your experience on our website. You can adjust your browser settings to reject cookies or be alerted when cookies are being used.

2. How We Use Your Information

We use the collected information for various purposes, including:

2.1. Providing Services: To provide web design and related services you have requested from us.

2.2. Communication: To respond to your inquiries, send updates, and provide customer support.

2.3. Analytics: To analyse and improve our website and services, as well as monitor usage patterns.

3. Information Sharing and Disclosure

We do not sell or rent your personal information to third parties. However, we may share your information with third parties under the following circumstances:

3.1. Service Providers: We may share your information with trusted service providers who help us deliver our services, such as hosting providers, analytics providers, and marketing services.

3.2. Legal Obligations: We may disclose your information when required by law, to comply with legal processes, or to protect our rights, privacy, safety, or property.

4. Your Choices

You have choices regarding your personal information:

4.1. Access and Update: You can access and update your personal information by contacting us.

4.2. Marketing Communications: You can opt out of receiving marketing communications from us by following the unsubscribe instructions in our emails or emailing [email protected]

5. Security

We take appropriate measures to protect your personal information from unauthorised access, disclosure, alteration, or destruction.

6. Links to Other Websites

Our website may contain links to third-party websites. We are not responsible for the privacy practices of these websites. We recommend reviewing their respective privacy policies.

7. Changes to this Privacy Policy

We may update this Privacy Policy from time to time to reflect changes in our practices. Any changes will be posted on this page, and the date at the top will indicate the latest update.

8. Contact Us

If you have any questions or concerns about this Privacy Policy or our practices, please contact us at: [email protected]

By using our website and services, you acknowledge that you have read and agree to this Privacy Policy. Different Colour Productions Ltd is committed to safeguarding your personal information and respecting your privacy rights.

ThreeBestRated Top 3 Website Designers in London 2026 award for DCP Web Designers Certificate