You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何获取HTML标签的display属性值?无需测试区分布局类型

提问内容

我不想通过测试标签是否支持width或height属性来区分inline与inline-block元素,也不想靠测试是否换行来区分block元素。我希望能像开发者工具里那种类似var_dump()的方式查看标签的属性,但可惜的是,它没法给img、span这类标签提供如下示例中textarea那样的完整属性信息:

textarea {
writing-mode: horizontal-tb !important;
font-style: ;
font-variant-ligatures: ;
font-variant-caps: ;
font-variant-numeric: ;
font-variant-east-asian: ;
font-variant-alternates: ;
font-weight: ;
font-stretch: ;
font-size: ;
font-family: monospace;
font-optical-sizing: ;
font-kerning: ;
font-feature-settings: ;
font-variation-settings: ;
text-rendering: auto;
color: fieldtext;
letter-spacing: normal;
word-spacing: normal;
line-height: normal;
text-transform: none;
text-indent: 0px;
text-shadow: none;
display: inline-block;
text-align: start;
appearance: auto;
-webkit-rtl-ordering: logical;
resize: auto;
cursor: text;
white-space-collapse: preserve;
text-wrap: wrap;
overflow-wrap: break-word;
background-color: field;
column-count: initial !important;
margin: 0em;
border-width: 1px;
border-style: solid;
border-color: -internal-light-dark(rgb(118, 118, 118), rgb(133, 133, 133));
border-image: initial;
padding: 2px;
}

内容的提问来源于stack exchange,提问作者aguyfrombrazil

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.15 04:43:18