Creating a new HTML element [duplicate] - html

This question already has answers here:
How to create custom tags for HTML [closed]
(6 answers)
Are custom elements valid HTML5?
(12 answers)
Closed 6 years ago.
Is there any problem if I define my own HTML element in this way:
mynewelement {
display: inline-block;
border: 3px solid;
border-color: red;
background-color: pink;
color: #000;
padding: 4px;
}
<mynewelement>Hello World</mynewelement>
Will this lead to problems in the browser?
For me it works fine, no problems detected, but I worry it's not the right way to create a web element supported by all browsers. Is this incorrect? Or is this the same thing like any other html element(div, em, small, etc) and no difference?
Are all html elements made in this way?

Related

How to create a horizontal dashed arrow for Squarespace [duplicate]

This question already has answers here:
How to animate a dashed arrow?
(2 answers)
Closed 2 years ago.
I'm just needing some HTML and CSS to create a normal dashed arrow in Squarespace.
I would like to customise the colour to #034472 and have similar style to the pic, pointing right, if possible.
Any help with this would be much appreciated!
span {
content: "\21E0";
font-size: 100px;
color: #034472;
}
<span style="color: #034472; font-size: 100px;">⇠</span>

how to make a div show [duplicate]

This question already has answers here:
HTML Div border not showing
(3 answers)
Closed 2 years ago.
I am trying to make a foot print for a cool look, but it won't show
here's my code:
.footprint {
width: 100px;
height: 50px;
border-color: gray;
border: 3px;
border-radius: 20px;
}
<div class="footprint"></div>
welcome to SO!
Somebody already found a solution to your problem here:
CSS Property Border-Color Not Working
A div by default has no border-style and no border-width, therefore the border will not be shown.

CSS and rem: changing the html font-size creates inconsistent dimensions [duplicate]

This question already has answers here:
Sub-Pixels calculated and rendered differently among browsers
(2 answers)
Closed 4 years ago.
I am using rems across all my project to calculate both font sizes and elements dimentions. The base html font-size used to be set at 10px. When I changed to 11 for design reasons, I noticed that a repeated line of .2rem height was not displayed consistently. Here is a codepen that can reproduce the issue: https://codepen.io/jalef/pen/djeoxK . If the html font-size is changed from 10 to 11 the same thing happens.
html {
font-size: 11px;
}
.line {
height: .2rem;
width: 50rem;
background-color: purple;
margin: 1rem;
}
The consistent .2rem height lines that are produced when html font-size is set to 10px:
The inconsistent .2rem height lines that are produced when html font-size is set to 11px:
Is there a reason why this is happening and is there a way to resolve it?
Thanks!
It might be that there are some browser rendering issues.
You can try to use a border instead of the height of div.
Example:
border-bottom: 0.2rem solid purple;

Why won't CSS class work in browser? [duplicate]

This question already has answers here:
Is there a reason why CSS doesn't support ids and classes, starting from numbers?
(8 answers)
Closed 8 years ago.
I have this html;
<div class="1"><br/>hi</div>
<div class="2"><br/>hi</div>
<div class="3"><br/>hi</div>
<div class="4"><br/>hi</div>
and then I added normal CSS formatting to the divs;
div{
height: 100px;
width: 100px;
border-radius: 100%;
margin: 20px;
display: inline-block;
text-align: center;
}
and then i wanted each div to be a different colour so I used the classes like this;
.1{
background-color: pink;
}
.2{
background-color: red;
}
.3{
background-color: orange;
}
.4{
background-color: yellow;
}
I am writing this in dreamweaver and when i click on the divs the little class thing tells me that they are coloured and the code is working, but when i preview in a browser the colours are not showing up and I just get the div part of the CSS.
it's probably very obvious but I can't think of why this is happening.
Thanks :)
Please avoid using classes with number at the beginning. It will fail for sure.
You can use for example cl1, cl2, cl3, etc.

Is it possible to have an :after pseudo element on a button? [duplicate]

This question already has answers here:
Why do the :before and :after pseudo-elements require a 'content' property?
(5 answers)
Closed 7 years ago.
I have a button and on a :hover I would like an after element to show. But I can't see it. Is it possible to have an :after element on a button?
.button {
cursor: pointer;
height: 30px;
}
.button-primary {
border: none;
}
.button-primary:hover:after {
display: block;
position: relative;
top: 3px;
right: 3px;
width: 100px;
height: 5px;
}
<button class="button button-primary">My button</button>
This should now work on all up to date browsers.
To get it to work, you need to add content:""; in your after.
Yes you can use it – as long as you as don't need to support some very old browsers, e.g. MS IE 7 or lower. I don't know of any other browser that doesn't understand pseudo elements on empty HTML tags. In fact I already used it in several production sites without any problems.