Link to home
Start Free TrialLog in
Avatar of doctorbill
doctorbillFlag for United Kingdom of Great Britain and Northern Ireland

asked on

CSS and custom tags

A CSS question:

Let's take the <td> tag as an example

Is it possible to make a custom css tag and use that to dictate the styling of any <td> tags inside it
ie
css page:
customtag > td
{
some condition
}
php page:
<customtag><td> text </td></customtag>

The reason for this is that I want to add a specific condition to a set of <td> tag's which already have defined css conditions defined for that particular tag in the css page in the rest of the php page
Avatar of Terry Woods
Terry Woods
Flag of New Zealand image

Why a custom tag and not just a <div> tag with a particular class, or for that matter, why not just add a class or id to an element on the page?
This may be of interest: https://stackoverflow.com/questions/5970093/using-custom-html-tags

The top 2 answers are worth a read. Long story short, if you create a custom tag, it should probably work, but it sounds like it's a good idea to ensure you put a hyphen character in the tag name (eg <my-tag>) to avoid the risk of the tag become a standard one in future.
You can add anything you like to your CSS.

However, for your custom tag to be processed, you'd somehow have to convince every visitor to your site to download some sort of hacked version of their browser, which you coded to process your custom CSS tag.

Highly unlikely approach to whatever you're trying to solve.

Just use CSS classes or style by element ID.
ASKER CERTIFIED SOLUTION
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of doctorbill

ASKER

Thanks all
Avatar of Brandon Lyon
Brandon Lyon

Just to clarify a bit of misinformation earlier in the thread, custom elements are possible. That said I wouldn't suggest using them in situations where a classname, id, or attribute would work just as well.

Here is a tutorial about custom elements https://blog.teamtreehouse.com/create-custom-html-elements-2