Web Basics: Div, Box Model, OG Tags, and Favicons

안동현·2025년 1월 22일

Frontend

목록 보기
2/4

The Role of Favicons

Favicons are small icons displayed in a browser's tab, bookmark, or favorite list. They help users easily identify a website.

How to Add a Favicon

  1. Prepare the Image

    • Recommended size: 16x16 or 32x32 pixels.
    • Supported formats: .ico, .png, .svg.
  2. Generate Favicons Using RealFaviconGenerator

    • Visit RealFaviconGenerator.
    • Upload your image → Click Next.
    • Adjust settings for platforms like iOS and Android.
    • Download the generated Favicon package.
  3. Insert HTML Code
    Add the following code in the <head> section:

    <head>
        <link rel="icon" type="image/png" href="./favicon-96x96.png" sizes="96x96" />
        <link rel="icon" type="image/svg+xml" href="./favicon.svg" />
        <link rel="shortcut icon" href="./favicon.ico" />
        <link rel="apple-touch-icon" sizes="180x180" href="./apple-touch-icon.png" />
        <link rel="manifest" href="./site.webmanifest" />
    </head>

Open Graph (OG) Tags

OG tags, developed by Facebook, control how website content is previewed when shared on social media platforms.

Key OG Tags

<head>
    <meta property="og:title" content="Page Title">
    <meta property="og:description" content="Page description">
    <meta property="og:image" content="https://www.example.com/image.jpg">
</head>

Benefits of OG Tags for SEO

  • Enhance social media visibility and engagement.
  • Indirectly contribute to SEO by increasing click-through rates (CTR).
    Recommendations:
  • Use a clear and attractive og:title and og:description.
  • Ensure og:image is high-resolution.

CSS Box Model

The CSS Box Model defines how elements are displayed and spaced on a webpage. Every HTML element is treated as a box with four layers:

  1. Content: The actual content inside the box.
  2. Padding: Space between the content and the border.
  3. Border: Surrounds the padding.
  4. Margin: The outermost space, separating the element from others.
.box {
  width: 300px;
  height: 200px;
  padding: 20px;
  border: 2px solid black;
  margin: 30px;
}

Box Sizing (box-sizing)

Defines how the total size of an element is calculated.

  • content-box: Width and height include only the content (default).
  • border-box: Width and height include padding and border.
.box-content {
  box-sizing: content-box;
  width: 300px;
  padding: 20px;
  border: 10px solid black;
}

.box-border {
  box-sizing: border-box;
  width: 300px;
  padding: 20px;
  border: 10px solid black;
}

Float and Clear

Float

The float property removes elements from the normal document flow, aligning them to the left or right. Text or inline elements flow around the floated element.

.image {
  float: left;
  margin-right: 10px;
}

Clear

The clear property prevents elements from being affected by preceding floated elements.

.container {
  clear: both;
}

Summary

For a backend developer, understanding web basics like the Box Model or OG tags can significantly improve collaboration with frontend teams. For example, when implementing a feature that dynamically generates HTML for product previews, knowing how OG tags affect social media previews ensures your API delivers the right meta-data. This not only enhances user experience but also streamlines communication between frontend and backend during development.

profile
내가 깨달은 것과 내가 리마인드할것

0개의 댓글