<path>

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

* Some parts of this feature may have varying levels of support.

Phần tử <path> của SVG là phần tử tổng quát để định nghĩa một hình dạng. Tất cả các hình cơ bản đều có thể được tạo bằng một phần tử path.

Ngữ cảnh sử dụng

CategoriesGraphics element, Shape element
Permitted contentAny number of the following elements, in any order:
Animation elements
Descriptive elements

Thuộc tính

d

Thuộc tính này định nghĩa hình dạng của path. Kiểu giá trị: <string>; Giá trị mặc định: ''; Có thể hoạt ảnh:

pathLength

Thuộc tính này cho phép tác giả chỉ định tổng chiều dài của path, tính theo đơn vị người dùng. Kiểu giá trị: <number>; Giá trị mặc định: không có; Có thể hoạt ảnh:

Giao diện DOM

Phần tử này triển khai giao diện SVGPathElement.

Ví dụ

html
<svg viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
  <path
    d="M 10,30
           A 20,20 0,0,1 50,30
           A 20,20 0,0,1 90,30
           Q 90,60 50,90
           Q 10,60 10,30 z" />
</svg>

Đặc tả

Specification
Scalable Vector Graphics (SVG) 2
# PathElement

Tương thích trình duyệt

Xem thêm