Files
2nd/10_Wiki/Topic_CSS/CSS_Horizontal_Navbar.md
T
koriweb 9609c04755 docs(10_Wiki): W3Schools 위키화 — HTML/CSS/JavaScript(core)
W3Schools 튜토리얼을 P-Reinforce v3.1 포맷으로 위키화(영어 본문, 한/영 섹션 헤더).
- Topic_HTML: 59문서 (튜토리얼+예제, 레퍼런스/메타 제외)
- Topic_CSS: 190문서 (메인 + Advanced/Flexbox/Grid/RWD 전체)
- Topic_JavaScript: 120문서 (코어 언어; Temporal/DOM상세/BOM/WebAPI/AJAX/jQuery/Graphics 등은 후속)
각 폴더 00_INDEX.md(MOC) 포함. 코드 verbatim, 미확인분은 "Not found in source" 표기.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-23 19:21:18 +09:00

6.2 KiB

id, title, category, status, verification_status, canonical_id, aliases, duplicate_of, source_trust_level, confidence_score, created_at, updated_at, review_reason, merge_history, tags, raw_sources, applied_in, github_commit
id title category status verification_status canonical_id aliases duplicate_of source_trust_level confidence_score created_at updated_at review_reason merge_history tags raw_sources applied_in github_commit
css-horizontal-navbar CSS Horizontal Navbar Frontend draft conceptual
horizontal navbar
top navigation
horizontal navigation bar
flex navbar
float navbar
sticky navbar
B 0.87 2026-06-23 2026-06-23
css
web
frontend
w3schools
navbar
navigation
https://www.w3schools.com/css/css_navbar_horizontal.asp

CSS Horizontal Navbar

🎯 한 줄 통찰 (One-line insight)

A horizontal navbar lays its list items side by side using either floating list items or a flexbox <ul>, then adds hover/active states, dividers, and fixed or sticky positioning. [S1]

🧠 핵심 개념 (Core concepts)

  • Float methodul li { float: left; } with overflow: hidden on the <ul> lays links horizontally. [S1]
  • Flex methoddisplay: flex on the <ul> arranges links in a row. [S1]
  • Block linksdisplay: block on a makes the full link area clickable. [S1]
  • Active classa.active marks the current link with a highlight color. [S1]
  • Fixed/sticky positioningposition: fixed (top/bottom) or position: sticky (with top) keeps the navbar in view while scrolling. [S1]

🧩 추출된 패턴 (Extracted patterns)

  • Two layout methods — floating list items (float: left) or a flex container (display: flex) both yield a horizontal row. [S1]
  • Dividersborder-right on each li with li:last-child { border-right: none; } removes the trailing divider. [S1]
  • Right-aligned itemstyle="float:right" on a single <li> pushes one link to the right. [S1]
  • Sticky requires an offset — at least one of top/right/bottom/left must be set for sticky to work. [S1]

📖 세부 내용 (Details)

Horizontal navbar with float [S1]

ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background-color: #333333;
}

ul li {
  float: left;
}

ul li a {
  display: block;
  color: white;
  text-align: center;
  padding: 14px 16px;
  text-decoration: none;
}

ul li a:hover {
  background-color: #111111;
}

Horizontal navbar with flex [S1]

ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  background-color: #333333;
  display: flex;
}

ul li a {
  display: block;
  color: white;
  padding: 14px 16px;
  text-decoration: none;
}

ul li a:hover {
  background-color: #111111;
}

Horizontal centered navbar with flex [S1]

ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  background-color: #333333;
  display: flex;
  justify-content: center;
}

Active state [S1]

ul li a.active {
  background-color: #04AA6D;
}

Gray horizontal navbar [S1]

ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  display: flex;
  border: 1px solid #e7e7e7;
  background-color: #f3f3f3;
}

Right-align the last link [S1]

<ul>
  <li><a href="#home" class="active">Home</a></li>
  <li><a href="#news">News</a></li>
  <li><a href="#contact">Contact</a></li>
  <li style="float:right"><a href="#about">About</a></li>
</ul>

Border dividers [S1]

/* Add a lightgray right border to all list items, except the last */
ul li {
  float: left;
  border-right: 1px solid #bbbbbb;
}

ul li:last-child {
  border-right: none;
}

Fixed top navbar [S1]

ul {
  position: fixed;
  top: 0;
  width: 100%;
}

Fixed bottom navbar [S1]

ul {
  position: fixed;
  bottom: 0;
  width: 100%;
}

Note [S1] Fixed position might not work properly on mobile devices.

Sticky navbar [S1]

ul {
  position: sticky;
  top: 0;
}

Note [S1] You must specify at least one of the top, right, bottom or left properties, for sticky positioning to work.

🛠️ 적용 사례 (Applied in summary)

The page's applied examples are the dark float navbar, the flex navbar, the centered flex navbar, the green .active link, the gray flex navbar, the right-aligned About link, border dividers, fixed top/bottom navbars, and the sticky navbar. No external project/commit applications found in the source.

💻 코드 패턴 (Code patterns)

Float-based horizontal navbar (language: CSS):

ul li {
  float: left;
}

ul li a {
  display: block;
  padding: 14px 16px;
  text-decoration: none;
}

Sticky navbar (language: CSS):

ul {
  position: sticky;
  top: 0;
}

⚖️ 비교 및 선택 기준 (Comparison & decision criteria)

  • Float vs Flex layout — The source presents two methods for laying out a horizontal navbar: floating the list items (ul li { float: left; }, with overflow: hidden on the <ul>) or using a flex container (display: flex on the <ul>). Both produce a horizontal row of links; the flex method additionally enables justify-content: center for easy centering. [S1]
  • Fixed vs Sticky positioningposition: fixed pins the navbar to the top or bottom of the viewport (but may not work properly on mobile), while position: sticky keeps it in flow until scrolled and requires at least one offset (top/right/bottom/left) to work. [S1]

⚖️ 모순 및 업데이트 (Contradictions & updates)

No contradictions found in the source.

검증 상태 및 신뢰도

  • 상태: draft
  • 검증 단계: conceptual (실제 적용 사례 발견 시 applied/validated로 승격 가능)
  • 출처 신뢰도: B (W3Schools — widely used educational reference, not a primary standards body)
  • 신뢰 점수: 0.87
  • 중복 검사 결과: 신규 생성 (New discovery)

🔗 지식 그래프 (Knowledge Graph)

📚 출처 (Sources)

📝 변경 이력 (Change history)

  • 2026-06-23: Initial draft synthesized from the W3Schools "CSS Horizontal Navbar" page (Astra wiki-curation, P-Reinforce v3.1 format).