개념/HTML+CSS

CSS) Semantic Web Page Layout with CSS Styling

kiseno 2025. 2. 18. 15:54
728x90
반응형
SMALL
<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>sementic layout</title>
        <style>
            *{margin: 0px; padding:5px 0px;}
            body{ font-size: 14px; width: auto; height: auto; margin: 0 auto; }
            section{ width: 80%; float: left; background: #E4F2D0; }
            aside{ width: 20%; float: right; background:#F1DCF2; }
            #article1 { font-size : 12px; background: silver; margin: 0px 10px; }
            header{ background: #085C3C; color:white; }
            footer{ background: #085C3C; color: white; clear:both; }
            nav{ background: olivedrab;}
            h1{ font-size : 11px; }
            h2{ font-size : 9px; }
        </style>
    </head>
    <body>
        <header><h1>header section</h1></header>
        <nav><h1>NAV section</h1></nav>
        <section id="section1">
            <h1>section1 section</h1>
            <p>write in any sentence</p>
        </section>
        <aside>
            <h1>Aside section</h1>
            <p>write in any sentence</p>
        </aside>
        <section id="section2">
            <h1>section2 section</h1>
            <p>write in any sentence</p>
            <article id="article1">
                <h2>article section</h2>
                <p>write in any sentence</p>
            </article>
        </section>
        <footer>
            <h1>footer section</h1>
        </footer>
    </body>
</html>

1. **Global Styles**:
   - The universal selector (`*`) is used to set a default margin and padding for all elements, ensuring consistency and removing default browser styling.
   - The body element is styled to adjust the font size and center the content with automatic width management.

2. **Layout Composition**:
   - **Header and Footer**: Both the header and footer stretch across the full width of the viewport, with a distinct background color (`#085C3C`) and white text, marking the top and bottom bounds of the page.
   - **Navigation (`nav`)**: Styled distinctly from the header and footer but with a complementary background color (`olivedrab`), indicating its role as a navigational element.
   - **Main Content (`section` and `aside`)**: The layout is divided into main content areas (`section`) and a sidebar (`aside`). The main content sections are floated left and take up 80% of the width, while the sidebar is floated right and takes up the remaining 20%, each with their own background color for visual separation.
   - **Article**: An article within the second section (`#section2`) demonstrates how to nest semantic elements, with specific styling to differentiate it from the surrounding content.

3. **Typography and Color Scheme**:
   - The document employs a basic color scheme that distinguishes different sections visually through background colors. Typography settings (such as font sizes for `<h1>` and `<h2>`) are reduced for heading elements within sections, possibly to maintain hierarchy and readability against the body's default font size.

4. **Layout Clearing**:
   - The `clear:both;` style on the footer ensures that it is rendered below the floated elements (`section` and `aside`), maintaining the intended layout flow.

### Key Points:
- The example effectively demonstrates how to structure a web page semantically, improving accessibility and SEO by using HTML5 semantic elements.
- CSS styling provides a clear visual distinction between each section of the page, though the choice of font sizes (especially smaller sizes for headings) might not align with conventional design principles focusing on hierarchy and legibility.
- The layout techniques employed, including the use of float for layout purposes, are traditional but might not offer the flexibility and responsiveness of modern CSS layout methods such as Flexbox or Grid.

### Possible Improvements:
- **Responsive Design**: Incorporate media queries to adjust the layout for different screen sizes, ensuring the page is readable and functional across devices.
- **Modern Layout Techniques**: Consider using CSS Flexbox or Grid for the layout to achieve more flexible and responsive designs without relying on floats.
- **Accessibility Enhancements**: Ensure that font sizes for headings are large enough for readability and that color contrasts meet accessibility standards.
- **Content and Aesthetics**: Further develop the content and visual design, including more meaningful text and enhanced styling, to create a more engaging and professionally polished webpage.

728x90
반응형
LIST