/    Sign up×
Community /Pin to ProfileBookmark

List of attributes in CSS for a given element

Hello. How can I find out a list of attributes a certain HTML element in CSS is styleable?

For example <p> is can be styled with margin-top. Thank you.

to post a comment
CSS

10 Comments(s)

Copy linkTweet thisAlerts:
@cootheadJul 19.2021 — Hi there codewitch,

here is a comprehensive list...

[url=https://developer.mozilla.org/en-US/docs/Web/CSS/Reference#Keyword_index][u][color=#00f][b]MDN[/b] - CSS Reference[/color] [/u][/url]

You can check out browser compatibility for each property here...

[url=https://caniuse.com/][u][color=#00f]Can I Use[/color][/u][/url]

[i]coothead[/i]
Copy linkTweet thisAlerts:
@codewitchauthorJul 19.2021 — Hello coothead. Thank you for the links you provided.

I am looking for something else. I am looking for list of all CSS attributes for a **specific** HTML element.

For example <img> can be styled with xxx (a complete list of attributes)

Another example <div> can be styled with yyy (another complete list of attributes)

(not every HTML element can be styled with every attribute)
Copy linkTweet thisAlerts:
@daveyerwinJul 19.2021 — @codewitch#1634362 said ...

I am looking for something else. I am looking for list of all CSS attributes for a specific HTML element.

____________________________________________________________

the list will be exceedingly long

try this code ...

``<i>
</i> &lt;!DOCTYPE html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;style&gt;
[xxx] {
background: yellow;
}
[xxs] {
background: green;
}

&lt;/style&gt;
&lt;/head&gt;
&lt;body&gt;

&lt;h2&gt;CSS Custom Attribute&lt;/h2&gt;

&lt;h1 xxx="top-header"&gt;Welcome&lt;/h1&gt;
&lt;p xxs="top-text"&gt;Hello world!&lt;/p&gt;
&lt;p class="topcontent"&gt;Are you learning CSS?&lt;/p&gt;

&lt;/body&gt;
&lt;/html&gt;<i>
</i>
``
Copy linkTweet thisAlerts:
@daveyerwinJul 19.2021 — @codewitch#1634362 said ...

not every HTML element can be styled with every attribute

______________________________________

Can you provide some code example to demonstrate this ?
Copy linkTweet thisAlerts:
@codewitchauthorJul 19.2021 — Hello DaveyErwin. Sure, here you go:

[CODE]
<img src="myimage.jpg" style="text-align: right; text-decoration: none" />
[/CODE]


(there is no text, there is just an image)
Copy linkTweet thisAlerts:
@daveyerwinJul 19.2021 — <img src="myimage.jpg" style="text-align: right; text-decoration: none" />


in the image tag above there are two attributes src and style
  • 1. src="myimage.jpg"

  • 2. style="text-align: right; text-decoration: none"


    they can be used for styling ...
    ``<i>
    </i>&lt;!DOCTYPE html&gt;
    &lt;html&gt;
    &lt;style&gt;
    [src]{height:44px}
    [style]{border-style: groove;
    border-color: coral;
    border-width: 7px;}
    &lt;/style&gt;
    &lt;body&gt;
    &lt;h1&gt;Hello World&lt;/h1&gt;
    &lt;p &gt;This is a paragraph.&lt;/p&gt;
    &lt;img src="https://daveyerwin.com/th.jpg" style="text-align: right; text-decoration : none" &gt;
    &lt;/body&gt;
    &lt;/html&gt;<i>
    </i>
    ``
  • Copy linkTweet thisAlerts:
    @cootheadJul 19.2021 — >@codewitch#1634362
    >
    >[color=navy]"I am looking for list of all CSS attributes

    >for a specific HTML element."[/color]


    As CSS properties are forever growing, the

    list that you seek would be forever changing. ;)

    The [b]MDN[/b] link that I provided has for each

    property a section called [b]Formal definition[/b]

    that indicates the elements to which the

    property may be applied.

    For example, let's say you wanted to use the

    [i]box-sizing[/i] property, clicking on that item

    would take you to this page...

    [url=https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing][color=#00f][u]box-sizing[/u][/color][/url]

    Scrolling down the page you come to this section...

    [url=https://developer.mozilla.org/en-US/docs/Web/CSS/box-sizing#formal_definition][color=#00f][u]Formal definition[/u][/color][/url]

    ...which gives this information...

    >[color=#000][b]Applies to[/b] . . . all elements that accept width or height[/color]

    This means, of course, that the property may

    be applied to the [i]img element[/i]

    The bottom line is this; don't waste your time

    seeking lists, instead just check to see if the

    CSS effect that you wish to implement can be

    applied to the element in question.

    [i]coothead[/i]
    Copy linkTweet thisAlerts:
    @sibertJul 19.2021 — > @DaveyErwin#1634371 [src]{height:44px}

    > [style]{border-style: groove;


    Just wonder what the benefits of [src] and [style] are?

    https://jsfiddle.net/pwr1d0v5/
    Copy linkTweet thisAlerts:
    @SempervivumJul 19.2021 — What came across my mind first was the function getComputedStyle:

    https://developer.mozilla.org/en-US/docs/Web/API/Window/getComputedStyle
    >The Window.getComputedStyle() method returns an object containing the values of all CSS properties of an element, after applying active stylesheets and resolving any basic computation those values may contain.

    I gave it a try and there was a disillusion: I took align-items as a property and img as an element where this property is not applicable obviously. But nevertheless it was listed.

    I took the same example and looked up in MDN. The result is "Applies to all elements"
    Copy linkTweet thisAlerts:
    @daveyerwinJul 19.2021 — @sibert#1634380 said ...

    Just wonder what the benefits of [src] and [style] are?

    __________________

    in this css ...

    <style>

    [src]{height:44px}

    [style]{border-style: groove;

    border-color: coral;

    border-width: 7px;}

    </style>

    [src] and [style] are selectors

    [src] selects all Elements that have 'src' as an attribute

    [style] selects all Elements that have 'style' as an attribute

    they have the same benefits as any other CSS Selector
    ×

    Success!

    Help @codewitch spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 4.23,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,

    tipper: @darkwebsites540,
    tipped: article
    amount: 10 SATS,

    tipper: @Samric24,
    tipped: article
    amount: 1000 SATS,
    )...