Is there such thing as custom selector?

When specifying CSS class, id or style I use p, span or div selectors but the problem is that those
have functions beside selecting. P does paragraph,
span lines up and div, well it puts stuff into container.

What I want is having selector that does none except calling CSS. It’s there such thing?

Thanks

I’m not 100% sure what you mean, but with

  • { }

you can cascade EVERYTHING once.

hello,

i think you want to create a new Selector :slight_smile: im kidding :slight_smile:

In fact you have to play around… if we you don’t need a specific P or Div to be Selected you add NONE to it… for example i need a Div to be red but the div inside i need it to be blank… so my markup will be :

.myredclass{
background:red;
}
.myredclass.myblankclass{
background:none;
}

i think you already gave the answer on your question :slight_smile:

I’m not really sure what you are requesting, either.

Most HTML tags are either block (which means they stretch to the full width of their container) or inline (in which case they align side by side like words in a sentence).

A <div> tag is a block tag with NO styles assigned.
A <span> tag is an inline tag with NO styles assigned.

Some tags are specialized and do indeed have default styles. <p> paragraph tags, <ul> unordered list and <ol> ordered list tags, <table> and table-related tags, <form> tags, the list goes on…, all have special properties preassigned… that’s why they exist. Part of learning HTML is knowing about those properties so you know when to use the tag.

HTML structures the page. CSS styles it.

CSS is assigned to tags/selectors either through the tagname, through a class/ID name, or combinations of those and more.

With CSS, you can add styles to selectors where desired and change default styles where needed.

Selectors do not “call” CSS styles, selectors “apply” apply them selectively. :slight_smile:

Hope this helps.

Am with everyone here, I am not sure what you mean in your question but…

ALL your HTML SHOULD have some sort of meaning ( I am guessing that’s what you meant by function) . If on the other what what you meant by function was how it looks /or flows on the page then slap yourself on he hand now… HARDER!!
OK. Styling should be separate from semantics (function/meaning) and that’s exactly what CSS is for… you can change the ‘look’ of almost any element using CSS.

BTW, There are a couple elements that come ‘style free’ notably: DIVs ( for when you need to wrap other elements) and SPANs ( fro wrapping inline elements and/or text)

there is also a concept in CSS called ‘specificity’ PART of which includes this patterns:
(for any element such as DIV)

  • will select all elements, regardless ( least specific)
    div : will select all div tags regardless of ID ,class, etc ( more specific)
    .className: will select ANY tags that HAS class=’ className’ ( even more specific)
    div.className: will select only DIV tags that HAVE class=’ className’( way more specific)
    div .className: will select ANY tag that HAS class=’ className’ and are INSIDE a DIV
    .className div: will select DIV tags that are inside any elements that has class=’ className’

and so forth.
So what you should really be considering is your level of specificity.

hope that helps