Help us understand the problem. What is going on with this article?

CSS 全称セレクタでall: initialを指定するとページタイトルが画面に表示される

More than 3 years have passed since last update.
*{
  all: initial;
}

全要素のスタイルをリセットしたいときに使うと思います。
しかし...

sample1.png

sample.gif

原因

*セレクタは 全ての要素をセレクト
all: initial は 全てのプロパティの値を初期値にする

つまり 「全ての要素に対して 全てのプロパティの値を初期値にします」 という事。
全ての要素の中に titleタグが含まれてプロパティが初期値になるため表示されます。

表示にどのプロパティが影響しているか

displayが影響しています

*{
  /* block, inline-block, table, flex... */
  display: inline;
}

と指定すると表示されます。

対策

  • not() 使う
*:not(title){
  all: initial;
}
  • bodyとbody以下を選択
body,body *{
  all: initial;
}

ブラウザ

Chrome , Firefox, safari で確認しました

Why do not you register as a user and use Qiita more conveniently?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away