Adding design elements to HTML 5 components

Are there any potential downsides to applying CSS to the <section>, <header>, <article>, and <footer> elements? I vaguely remember reading somewhere that these elements should not be styled, but I can't seem to locate the source and I can't identify a valid reason to avoid using them.

In my new web layout, I am heavily utilizing these elements. Currently, I am hesitant to assign classes or standard CSS styles to them, although I am struggling to find a legitimate reason for this hesitation aside from vague recollections of cautionary advice.

Allow me to provide an example of my usage:

<body>

    <header>
        Header of the page
    </header>

    <div class="wrap">

        <div class="content-list">
            <article>
                <header>
                    <h1>Article title</h1>
                </header>
                <p></p>
                <p></p>
                <footer>
                    <a href="#">Read more</a>
                </footer>
            </article>
        </div>

    </div>

    <footer>
        Footer of the page
    </footer>

</body>

Occasionally, within the div with the content-list class, there is an unordered list where each list item contains an article structured similarly to what is currently displayed. The header in the article is always styled as white, while the footer consistently features a "read more" link (or some other exit link). The paragraph elements contain various content.

I am questioning this because I am customizing the appearance of the h1 element inside the header and the anchor tag inside the footer. However, it occurred to me that styling the header itself could potentially eliminate the need for separately styling the h1.

Answer №1

While <section>, <header>, <article>, <footer> and other HTML5 tags have specific meanings, they can still be styled to fit your desired look.

For instance, a <footer> doesn't have to adhere to the default visual style on every page it appears on. This is where CSS comes into play, allowing you to customize its appearance according to your application's needs. However, remember that a <footer> should primarily focus on content relevant to footer information, rather than content that should belong in a <p> or <article>.

Answer №2

One important concept to remember is the cascading nature of CSS, where rules are applied to parent tags that can affect child elements.

There's no issue with this approach, as long as you keep it in mind.

Ultimately, achieving your desired outcome depends on understanding how to navigate the cascade and finding the most straightforward path.

Answer №3

Using CSS with <section>, <header>, <article>, <footer> poses no disadvantages. These elements are part of HTML5 and are designed to improve the SEO friendliness of a website.

<section> indicates the beginning of main content, <header> refers to the header section of the site, <aside> represents a sidebar or similar component, <footer> denotes the footer of the website, while <article> signifies a specific block of content or paragraph.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Mixing percentage width with a fixed minimum width in CSS results in divs failing to align in a single line

Having an issue with the responsiveness of a website layout that includes three columns (let's say 'A', 'B', and 'C') each 96% high, along with a footer. Columns A and C have a width of 35%, while column B is set to be 30 ...

Aligning Content in the Middle of a Bootstrap Row

I'm struggling to horizontally center the content in the "row" class div. I've attempted using justify-content-center and other variations. <div class="container"> <div class="row"> <div class="col-md-4 portfolio-item ...

Using Jquery to select and apply functions to specified div elements

As someone who is relatively new to JQuery, I have a question regarding the .on() function. Take this example: $('div').on('click', function() {$(this).toggleClass('show-description');}); This code selects all the 'div& ...

Differences between visibility property manipulation in HTML and JS

One issue I am facing is that when I add a hidden property to a button in the HTML, it remains invisible. <button id="proceed_to_next_question" hidden> Next Question </button> However, if I remove the hidden property and include the following ...

What is the best way to align Bootstrap icons in the middle of buttons?

Currently, I am incorporating bootstrap icons into my design. Feel free to explore the provided DEMO. It showcases the issue of the bootstrap icons not aligning in the same line as the text inside the button. I am seeking advice on how to centralize the i ...

Click on the entire Material-UI formControlLabel to select it, not just the text

I have recently started working with the material UI. Currently, I am dealing with a form that looks like this: <FormControl variant="outlined" className={css.formControl} margin="dense" key={"abc_" + index} > <FormControlLabel cont ...

Using HTML and JavaScript to verify email addresses

I have been working on an "Email Validation" code, but it seems to be malfunctioning. I can't figure out why. Would you mind taking a look at it? Thank you. I suspect that the issue lies with this line document.getElementById("custEmail").onchange = ...

The HTML Canvas seems to be malfunctioning for some unknown reason

As a beginner in programming, I am struggling to understand why the code below is not working. The first three lines of the script are necessary for another part of the webpage, but I don't see how that would affect the rest of the code: <!DOCTY ...

Make the Angular Modal scrollable except for when a specific div is being click dragged

I am working on an Ionic app that uses AngularJS. One issue I encountered is with a modal popup that can sometimes extend beyond the visible area. To address this, we applied overflow: hidden to its CSS class. However, there is a specific functionality i ...

Engage the PROTRACTOR refresh function

I'm just getting started with automation and Protractor. I successfully automated the login page, but now I'm facing a challenge with accessing a menu that I need in order to navigate to a different page. Within the menu, there is an href="#/dom ...

What steps can be followed to incorporate a loading gif into this popup and subsequently eliminate it?

These simple inquiries are starting to get on my nerves. I can't keep waiting around for my website designer to resolve this issue. It shouldn't be that difficult... I managed to figure out most of it by researching similar questions, but I could ...

Utilizing Vue.js to incorporate the isActive property to the class name within a v-for loop, along with implementing dynamic class names

I am currently using a loop to iterate through some data in my store.js file, and everything is functioning as expected. However, I would like to add a condition to check if the Vue instance is active before applying a specific class to the polygon element ...

What effect does setting div1 to float left have on the layout of div2 in css?

Behold the mystical code written in HTML. <div id="sidebar1"> sidebar1 </div> <div id="sidebar2"> sidebar2 </div> Beneath lies the enchanting CSS code for the aforementioned HTML structure. div { width: 100px; ...

Has a newly created element been styled or are all values set to default since it is outside of the DOM?

First, I begin by creating an element: let link = document.createElement('a'); After my document is fully loaded and all styles and scripts are applied. The styles may look something like this: a { background-color: salmon; } Therefore, it w ...

The Flask form within the Bootstrap input-group is breaking onto a new line when viewed on mobile devices

I want the 'Go' button to remain next to the search field. It displays correctly on Desktop view, but on mobile view, the submit button wraps (breaking up the input-group). How can I prevent this? Additionally, Bootstrap is adding gray lines aro ...

Receive the innerHTML of an Element after appending additional Elements - Selenium

When working with my table in HTML, I have noticed that the <td> tag can be accessed in two different ways: 1. <td><font size="4" face="Arial"><i>Google</i></font></td> 2. <td>Google</td> I am curr ...

trigger a function when the iframe is altered

I am currently working on creating a function that can process credit card payments using an iframe. The challenge I am facing at the moment is dealing with error messages appearing in a less than ideal manner. Photo: I have been attempting to capture the ...

unable to download file and missing image display

I need assistance with creating a download link using the anchor tag in my code. However, the link is not working as expected and the image is not displaying either. <td><img src="{{book.book_image}}" alt="{{book.name}}" width= ...

Child div height (with embedded iframe) - issue with responsiveness

I have been working on a simple code for a day now, trying to solve a problem with no progress :( My goal is to display an iframe with a background image. However, the snippet code I have is not showing the background image as intended. You can view the li ...

In Groovy (or Java), learn the techniques to properly escape double quotes within HTML inner text while leaving attributes untouched

I am currently utilizing an HTML rendering engine that is based on Groovy within a Web Content Management (WCM) system. I have encountered a scenario where the user inputs rich text content into a form based on TinyMCE, which appears as follows: <p> ...